Do I need to explicitly call the base virtual destructor?

Nick Bolton picture Nick Bolton · Mar 24, 2009 · Viewed 143.1k times · Source

When overriding a class in C++ (with a virtual destructor) I am implementing the destructor again as virtual on the inheriting class, but do I need to call the base destructor?

If so I imagine it's something like this...

MyChildClass::~MyChildClass() // virtual in header
{
    // Call to base destructor...
    this->MyBaseClass::~MyBaseClass();

    // Some destructing specific to MyChildClass
}

Am I right?

Answer

Lou Franco picture Lou Franco · Mar 24, 2009

No, destructors are called automatically in the reverse order of construction. (Base classes last). Do not call base class destructors.