Polymorphism lets code call a common interface while the referenced object's concrete subclass supplies the behavior. In C++, a subclass overrides a superclass member function when both functions share the same signature. section 1.8 section 7.1.1
Tax calculation through a superclass pointer
Declare amount_owed() virtual in GeneralTax, then override it in LocalTax and MaxTax. A GeneralTax* pointing to a LocalTax or MaxTax object dispatches amount_owed() at run time to the matching subclass implementation. The same call can therefore produce general, local, or combined tax calculations without changing the calling code. section 7.1.1
Use polymorphism to:
- Code to an interface that supports multiple subclasses instead of coupling callers to one concrete subclass. section 2.4
- Extend behavior through overriding while keeping existing calling code stable. section 2.4
- Avoid unnecessary subclass hierarchies when simpler data structures would reduce complexity. section 2.4








