Should base class destructors be virtual?
Show answer and explanation
A base destructor should be public and virtual when objects may be deleted through base pointers. If deletion through the base is forbidden, a protected non-virtual destructor is a valid alternative; adding virtual solely by habit imposes polymorphic layout.
A base destructor should be public and virtual when objects may be deleted through base pointers. If deletion through the base is forbidden, a protected non-virtual destructor is a valid alternative; adding virtual solely by habit imposes polymorphic layout.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.