If you’ve made it this far, congratulations! You’re about to scale the highest peak of all in the mountain range of object-oriented concepts: polymorphism. It is the key to making objects truly independent.
Remember that objects—which are instances of classes—are data items that have built-in behavior. More than anything else, this ability of an unknown object to bring in new kinds of behavior—essentially plugging new software into an existing framework—makes good on the promise of object orientation.
Virtual functions are at the core of polymorphism. To understand why they are useful, let’s look at an example building on the Fraction class.
The FloatFraction ...