Modes of Inheritance

In this lesson, we'll learn about how Public, Private and Protected inheritance is done in C++.

You are already familiar with Access Modifiers from the Classes chapter. By using these specifiers, we limit the access of the data members and member functions to the other classes and main.

private Mode of Inheritance

By using private inheritance, the private data members and member functions of the base class are inaccessible in the derived class. Protected and Public members of the base class are accessible to the derived class and behave as private members of the derived class.

Note: any classes inheriting from the above-derived class remain unaware (that is, do not have access) of the base class.

Let’s look at the implementation using private inheritance:

Get hands-on with 1200+ tech skills courses.