Starting with the previous Rodent hierarchy, add a non
virtual destructor, create an object of class Hamster using
new, upcast the pointer to a Rodent*, and delete the
pointer to show that it doesn’t call all the destructors in
the hierarchy. Change the destructor to be virtual and
demonstrate that the behavior is now correct.
Starting with the previous Rodent hierarchy, add a non virtual destructor, create an object of class Hamster using new, upcast the pointer to a Rodent*, and delete the pointer to show that it doesn’t call all the destructors in the hierarchy. Change the destructor to be virtual and demonstrate that the behavior is now correct.