C++ Single Inheritance

If a single class is derived from one base class then it is called single inheritance. In C++ single inheritance base and derived class exhibit one to one relation.

C++ Single Inheritance Block Diagram

As shown in the figure, in C++ single inheritance only one class can be derived from the base class. Based on the visibility mode used or access specifier used while deriving, the properties of the base class are derived. Access specifier can be private, protected or public.

In this program class derive is publicly derived from the base class base. So the class derive inherits all the protected and public members of base class base i.e the protected and the public members of base class are accessible from class derive.

However private members can’t be accessed, although, we haven’t used any private data members in the base class.

With the object of the derived class, we can call the functions of both derived and base class.

Related Articles:

C++ Hierarchical Inheritance When several classes are derived from common base class it is called hierarchical inheritance. In C++ hierarchical inheritance, the feature...

C++ Multilevel Inheritance If a class is derived from another derived class then it is called multilevel inheritance. So in C++ multilevel inheritance,...