Saturday, October 10, 2009

Significance of virtual destructors...

Earlier i thought that virtual destructor are used to make sure that all the data pointers, memory blocks are freed when object gos out of scope...

But the actual significance of virtual keyword is that it allows the derived classes to override the base class destructors... this way when we delete the object of derived class at the end of all our work then derived class destructor is also called...


This link explains this better...
http://www.codersource.net/cpp_virtual_destructors.html

No comments:

Post a Comment