C++ Virtual Destructors and Base Classes

I’ve been wondering what happens when a derived class defines a virtual destructor. What about its base destructors? Are they called? If so, when? I finally read the right paragraph in The C++ Programming Language (pg 70):

A virtual destructor is essential for an abstract class because an object of a derived class is usually manipulated through a pointer to a base class. Then, the virtual function call mechanism ensures that the proper destructor is called. That destructor then implicitly invokes the destructors of its bases and members.

Still not sure when the bases and members are destructed, presumably after the derived virtual destructor…

Leave a Reply