A virtual destructor is just a virtual function, so it follows the same rules.
When you call delete a , the destructor is implicitly called. If the destructor is not virtual, you call a->~A() , because it is called like any other non-virtual function.
However, if the destructor is virtual, you call ~B() , as expected: the destructor function is virtual, so the invoked call is the destructor of the derived class, not the base class.
Edit:
Note that the base class destructor will be invoked implicitly after the derived class destructor completes. This is different from ordinary virtual functions.
source share