This chapter introduces the concepts and shows some examples of how to define inheritance relationships between C++ classes. Overriding methods, the
virtual keyword, and simple examples show how polymorphism works.
Inheritance is a particular way to organize classes that is supported by all object-oriented languages. It enables classes to share code in many different ways and to exploit natural relationships between classes. It can also make well-designed classes more reusable.
To employ inheritance, you place the common features of a set of related classes together in a base class and then derive other, more specialized classes from it. Each derived class inherits all the members ...