What is a pure virtual destructor?
All destructors should be implemented as virtual if the class is meant to be a base class (ie; another class is meant to inheret from it). A destructor cannot be pure virtual since the derived class must have its own implementation of all the clean up needed in the destructor function. When a object goes out of scope (or when the object is deleted) the compiler calls the derived class destructor but it also calls the base class destructor which it wouldn't do for any other polymorphic function.

0 Comments:
Post a Comment
<< Home