Class cannot behave polymorphically for deletion of derived class objects
This defect occurs
when a class has virtual functions but not a virtual destructor.
The presence of virtual functions indicates
that the class is intended for use as a base class. However, if the
class does not have a virtual destructor, it cannot
behave polymorphically for deletion of derived class objects.
If a pointer to this class refers to a derived class object, and you use the pointer to delete the object, only the base class destructor is called. Additional resources allocated in the derived class are not released and can cause a resource leak.
One possible fix is to always
use a virtual destructor in a class that contains virtual functions.
| Group: Object oriented |
| Language: C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax: DTOR_NOT_VIRTUAL |
| Impact: Medium |