callmeFilip / Thinking-in-CPP-Volume-1-2nd-Edition

Homework and Classwork repository
0 stars 0 forks source link

Chapter_15 Task_09 #303

Open callmeFilip opened 3 years ago

callmeFilip commented 3 years ago

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.