As I understand it, the purpose of a virtual virtual function is virtual, to force derived classes to either provide an implementation for it, or select a default implementation by explicitly writing Base::f() in Derived::f() .
So, if so, what is the purpose of creating a pure virtual virtual destructor? Does it force derived classes to provide an implementation for Base::~Base() ? Can derived classes implement Base::~Base() ? Not.
Thus, the first version with a virtual destructor seems sufficient for almost all purposes. In the end, the most common goal of a virtual destructor is that clients can correctly delete objects of derived classes through pointers of type Base* .
However, if you make all functions in Base only virtual, not pure virtual and provide them with an implementation (in fact you should provide), and at the same time you want to make Base abstract type, then having a pure virtual destructor in Base is the only solution :
class Base { public: virtual void f() {};
Hope this helps.
Nawaz
source share