Skip to content

Files

Latest commit

 

History

History
11 lines (6 loc) · 553 Bytes

virtualDestructor.md

File metadata and controls

11 lines (6 loc) · 553 Bytes

Pattern: Missing virtual destructor

Issue: -

Description

Class Base which is inherited by class Derived does not have a virtual destructor. If you destroy instances of the derived class by deleting a pointer that points to the base class, only the destructor of the base class is executed. Thus, dynamic memory that is managed by the derived class could leak. This can be avoided by adding a virtual destructor to the base class.

Further Reading