Remember:
A base class with polymorphic properties should declare a virtual destructor. If class has any virtual functions, it should have a virtual destructor.
The design purpose of class is not to declare a virtual destructor if it is not used as a base class, or if it is not for polymorphism.
class timekeeper {public: timekeeper (); ~timekeeper (); ...}; class Public timekeeper {...}; class Public timekeeper {...}; Timekeeper// Get an object pointer to derived class ... delete ptk; // because timekeeper with a non-virtual destructor, the destructor of the derived class is not called, resulting in a resource leak.
To solve this problem, we need only
class timekeeper {public: timekeeper (); virtual ~timekeeper (); ...};
The purpose of the virtual function is to allow the implementation of the derived class to be customized. Any class with the virtual function is almost certain that there should be a virtual destructor as well.
If class does not contain a virtual function, it usually means that it is not used as a base class, so its destructor does not need to be virtual.
With the pure virtual destructor, you must provide a definition for this pure virtual destructor.
class Amov {public: virtual0;}; Amov::~amov () {}
Effective C + + clause 07: Declaring a virtual destructor for a polymorphic base class