Your derived type has not yet been created.
Class Cat : Animal {
When you create a Cat object creation, the following happens:
- Build an animal
- Construct cat
When your object goes out of scope or is destroyed with delete, if on the heap, the following happens:
- Destroy cat
- Destroy animals
For this reason, you should not call virtual functions in your constructor or destructor. You would even have a pure virtual function call if you did not have an implementation in your base class.
You need:
GUIListbox lb; lb.SetupCallbacks();
The point of the virtual is that you can do things like:
GuiWindow *lb = new GuiListbox(); lb->SetupCallback();
source share