I understand that we should use virtual destructors in base classes to ensure proper resource disposal, because it guarantees the inheritance chain will be observed and all parent destructors will be called when destructing an object. That being said, do we also need virtual destructors in base classes when both the base class and any subclasses use only the default destructor? Example:
class Printable {
virtual std::string print();
};
class A : public Printable {
int foo;
bool bar;
std::string print() override;
}
class B : public Printable {
std::vector<int> foo;
std::string print() override;
}
There are no resources being managed, and all destructors are implicitly default. Is it still advisable to specify a virtual destructor in Printable
?