Determine whether several pairs of example classes fit the definition of class and subclass.
In our student/graduate student example, grad_student is the derived class and student is the base class.
The use of the keyword public following the colon in the derived class header means that the protected and public members of student are to be inherited as protected and
public members of grad_student. Members that are private are inaccessible.
This is referred to as public inheritance.
Public inheritance also means that the derived class grad_student is a subtype
Thus, a graduate student is a student, but a student does not have to be a graduate student. This subtyping relationship is called the ISA
relationship. This is also called interface inheritance
A derived class is a modification of the base class that inherits the public and protected members of the base class.
The only members that cannot be inherited are constructors and any member function that overloads the assignment operator.
Let us look at an example of public inheritance
using the student and grad_student classes.
Derived-class member functions might require access to base-class data members and member functions. A derived class can access the non-private members of its base class. Base-class members that should not be accessible to the member functions of derived classes should be declared private in the base class.
A derived class
can change the values of private base-class members, but only through non-private member functions provided in the base class and inherited into the derived class.