Inheritance is an important part of C++ and the Object Oriented Paradigm. It further expands on the concept of Classes and Objects, and introduces the idea of Parent Classes and Child Classes, where the Child Classes “inherit” variables and functions from the Parent.
Inheritance introduces a higher degree of Abstraction, Flexibility and Re-usability that if used properly, can dramatically improve the quality of your code and save you alot of time amongst other benefits.

Note: The terms Parent Class and Base Class, and Child Class and Derived Class are interchangeable with each other.
Understanding Access Modifiers
Before we begin, let’s do a review of Access Modifiers in C++. These play an important role when we inherit from one Class to another, so knowing exactly what they do is key.
There are three Access Levels in C++, Private, Public and Protected. Access Levels are basically “Protection” levels, which state how much access is being allowed for a certain function/variable. Access modes are used in two different situations. When defining member variables and functions, and when inheriting from classes.
Private:
The default Access Mode for most situations, because it’s the most secure option. The “Private” Access Mode means that only members within that class can access each other. Any attempt by external code to access private variables/methods with the private keyword, will be restricted.
In easier words, a private method/variable can only be accessed within the Class in which it was declared. Even Child Classes cannot access the private members from the Parent. If a Child Class inherits from a Parent Class, only the Public and Protected members will be inherited.
For private variables, we often make “setters” or “getters”, which allow external code to modify/get the values of the variable in question. The difference being however, we get to limit/control how the user modifies that variable.
Public:
Public is an Access Mode setting where it basically “public” and accessible to anyone, inside or outside of the Class. Any variable can be accessed or modified and any function can be called.
Protected:
Protected is a rather special Access Mode used only during Inheritance of Classes. Sometimes we want our variables or methods to be private, but we want the Child Classes to be able to access them without making them public.
In such cases, we use the Protected Keyword on variables/functions in the Parent Class, which allows Child Classes to access them, while keeping them private for all other purposes.
Inheritance in C++
When inheriting from a Base Class, you need to specify the access level of the Inheritance you want. There are three different access levels of Inheritance, private (default), public and protected. The member variables and function that get inherited from the Base Class, depend on the type of Inheritance used.
The one thing common across all Inheritances, is that the private variables and functions never get inherited. However, what does change is the access level of the public and protected members inherited.
Private Inheritance
Private Inheritance is the default inheritance type, if you inherit without mentioning a type.
class Person { };
class Student : private Person {};
In this inheritance, all the public and protected members are inherited as private. Hence if a public variable called “name” was inherited from “Person” through private inheritance, it will be a private member in “Student”.
