Re: Question about virtual destructor

Hello!

Me class derives from class, which doesn't provide virtual destructor. I declared virtual destructor in my class. Would object destruction work the same as in class derive from class with virtual destruction?

Re: Question about virtual destructor

Hi,

When you add virtual destructor it works as other virtual methods. So if you use a pointer to a base class object, which refers to derived class object and call delete on this object you will get ~Derived() and then ~Base(). And that is a correct behavior. If you don't have a virtual destructor in Base class you will not be able to destruct an object of Derived class through the pointer to Base.