Single Inheritance In C++

Card image cap

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.

Card image cap

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
};
Card image cap

Example 1:



Output :

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