Single Inheritance in C++ by R4R Team

What is Inheritance in C++ :
In C++,
-Inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such way, you can reuse, extend or modify the attributes and behaviors which are defined in other class.

Type of Inheritance in C++:
-Single Inheritance
-Multiple Inheritance
-Multilevel Inheritance
-Hierarchical inheritance
-Hybrid inheritance

1.Single Inheritance:
-When a parent have only one child then it is called single Inheritance.
class parent
class child: public parent


#include< iostream>
using namespace std;
class Home{
int price=10000;
class Room: public Home {
int count=5;
int main(void) {
Room obj;
cout<<"Price is: "<< obj.price<< endl;
cout<<"Number of Room: "<< obj.count<< endl;
return 0;


Price is: 10000
Number of Room: 5

-In this program, we create a object of child class and access data member of parent because of inheritance.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!