Do we need virtual destructor if we do not dynamic content in the derivative class?

Hello,

If my class A derivatives from class Base and A does not have any dynamic data, do I need to define the destructor of A or to make the destructor of class Base virtual?
closed account (zb0S216C)
Make sure the destructor of Base is virtual; otherwise, it will not be called. My rule of thumb is that if I inherit from a class, make the destructor of the base class virtual, only if there's dynamically allocated memory involved.

Edit:

Also, make the destructor virtual if there's virtual members in the base class.

Wazzak
Last edited on
Ok, thank you : )
Topic archived. No new replies allowed.