I am a little confused about virtual and pure virtual destructors. Why and when they are used? Can I get a good explanation for needing them? (I hope that's not too much to ask )
Anyway, all I know is that the following code will crash; can someone explain why? And why do I need to use virtual destructors to correct it?And if you can, I'm just curious about what a 'pure virtual destructor' isCode:class A { public: ~A() {} int a; }; class B { public: ~B() {} int b; }; class C : public A, public B { }; int main() { A* ap = new C; delete ap; B* bp = new C; delete bp; return 0; }
Meh?