Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual Destructors ?

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
BE
Who can tell me somthing about virtual destructors?
I need them but don't know how to use them.

eg.

I have an class called drawings;
Also I have a new class derived from drawings calls circle,and another class derived from drawings calls rectangle.

If I create an array of pointers to "drawings" , the destructor of the class drawings will be called,when I delete the array. I don't want that, because the array contains circles and rectangles. The only possible solution:virtual destructors.


Any help would be great.


thnx.


Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
yes, I found it.

just make the base class destructor virtual and the childrens destructor will be called automatically.
That easy! Greetz,

The Muppeteer.

themuppeteer@hotmail.com

Don't eat yellow snow...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top