In this recipe, you will learn more about two important OOP concepts, inheritance and polymorphism, which have been mentioned already and used in the examples of the previous recipes. Together with aggregation, these concepts make the design more extensible.
Using inheritance and aggregation
Getting ready
Inheritance is the ability of one class to get ownership of the non-private fields and methods of another class.
The extended class is called the base class, superclass, or parent class. The new extension of the class is called a subclass or child class.
Polymorphism is the ability to use the base class type for the reference to an object of its subclass.
To demonstrate the power of inheritance and polymorphism, let&apos...