Understanding single inheritance basics
Inheritance is the C++ language mechanism that allows the concepts of generalization and specialization to be realized. Single inheritance is when a given class has exactly one immediate base class. Both single inheritance and multiple inheritance are supported in C++; however, we will focus on single inheritance in this chapter and will cover multiple inheritance in a later chapter.
Inheritance hierarchies can be built using both classes and structures in C++. Classes, however, are most often utilized rather than structures to support inheritance and OOP.
Growing an inheritance hierarchy for the purpose of generalization and specialization supports an Is-A relationship. For example, given a base class of Person
and a derived class of Student
, we can say a Student Is-A Person. That is, a Student
is a specialization of a Person
, adding additional data members and member functions above and beyond those provided by its base class, Person
...