Linker chokes on virtual methods
I don't know if this is a Qt issue, or that I'm not chaining my virtual types correctly. I am getting the same thing on a number of virtual functions. Below is an example.
I have
Code:
class entity_ao {
public:
...
virtual void setToZero();
...
}
class scalar_ao : public entity_ao {
...
}
class real_ao : public scalar_ao {
public:
...
void setToZero() { ... }
...
}
This compiles just fine, but the .NET 2003 linker says: LNK2001: unresolved external symbol public: virtual void __thiscall entity_ao::setToZero(void)
I have tried adding virtual void setToZero(); to class scalar_ao, but that changes nothing. I have also tried moving the defn forreal_ao::setToZero from the .h to a .cpp file -- again that changes nothing.
Re: Linker chokes on virtual methods
Ignore my post on this subject. I just figured out that the base class needs an instantiation of the virtual function. Doing that gets rid of the linker errors.
K.
Re: Linker chokes on virtual methods
You can also make the method pure virtual in the base class:
Code:
class entity_ao {
public:
...
virtual void setToZero() = 0;
...
}
The linker won't complain then.