Single Inheritance In 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

As shown in the figure, in C++ single inheritance only one class can be derived from the base class.

Syntax:

  class subclass_name : access_mode base_class
{
	.........
	.........
  //body of subclass
};

Example 1:



Output :

x: 11
Enter the value of x = 3
Enter the value of y = 4
Product = 12