Polymorphism destructors

Oct 25, 2010 at 3:10pm
First of all , i apologizes if this was asked before , and for my bad English.

My question is about the polymorphism tutorial , the last example.

I created constructors and destructors for each class and added something like this to each one :
cout<<"*name of class* created"<<endl;
cout<<"*name of class* deleted"<<endl;

when I run the app I get this output:
CPolygon created
CRectangle created
CPolygon created
CTriangle created
20
10
CPolygon deleted
CPolygon deleted
Press any key to continue . . .

I noticed that the child classes don't get deleted. My question is why?
and if I can do something about this.
Oct 25, 2010 at 4:07pm
Did you put virtual in the destructor?
Oct 25, 2010 at 4:12pm
thank you ne555 for your quick reply. It seems to be working now
Topic archived. No new replies allowed.