You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

When the destructor is called on an object of a class that is part of a class hierarchy, both the derived class's and the base class's destructors will be called (in that order). However, if the derived class is referenced by a pointer of the a type higher up the inheritance hierarchy, then only the base class's destructor will be called. This can result in unintended program behavior. To correct this problem, virtual destructors should be declared for base classes within a class hierarchy.

Non-Compliant Code Example

Compliant Solution

  • No labels