Quick question. So I have a base class, and I make the destructor virtual to make sure any inherited classes are cleaned up properly:
class Base
{
virtual ~Base() {}
}
Now, if I make a child class that inherits from Base, and it doesn't need to deallocate anything for itself, do I need to explicitly make another empty virtual destructor so that any further subclasses get cleaned up, or does the virtual carry through from the Base. Example:
class Sub : public Base
{
// Various methods, but nothing to clean up so no destructor
}
class SubSub: public Sub
{
~SubSub(); // This has a destructor!! Now if I call delete on a Base*,
// will this destructor still get called without Sub also
// having a virtual destructor?
}
I know I could just be safe and put a virtual destructor in each class, but I like to have minimal code, I find it makes everything easier.