Create a Base class without a virtual destructor and a Derived class that allocates an array in its constructor and deletes it in its destructor. Track allocation and deletion with print statements.
Create a Derived object using new and assign it to a Base pointer. Delete through the Base pointer. Observe that the Derived destructor doesn't run and the array leaks. Add virtual to Base's destructor and repeat.
Now both destructors run in the correct order. This demonstrates why virtual destructors matter for polymorphic hierarchies.