Why the virtual destructor?
Whenever
You say delete p, and
The type of p is “pointer to base,” and
p actually points at a derived object
Then the base class must have a virtual destructor, even if it does nothing
Previous slide
Next slide
Back to first slide
View graphic version