Chapter 7. Creating Class Hierarchies
In the previous chapter, you learned how to create classes, add attributes and methods, and instantiate object instances of the classes in client code. This chapter introduces the concepts of inheritance and polymorphism.
Inheritance is one of the most powerful and fundamental features of any OOP language. Using inheritance, you create base classes that encapsulate common functionality. Other classes can be derived from these base classes. The derived classes inherit the properties and methods of the base classes and extend the functionality as needed.
A second fundamental OOP feature is polymorphism. Polymorphism lets a base class define methods that must be implemented by any derived classes. The base class ...