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 a type higher up the inheritance hierarchy, then only that 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.