class Base{ public: Base(); ~Base(); }
class Child : public Base { public: Base(); ~Base(); } int main() { Child *c = new Child(); Base *b = c; delete b; return 0; }
Define the destructor with the virtual keyword:
virtual
class Base{ public: Base(); virtual ~Base(); }
Another issue: The constructor and destructor of the Child class, should be named Child() and virtual ~Child() (instead of Base() and ~Base()).
Child
Child()
virtual ~Child()
Base()
~Base()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)