SlideShare a Scribd company logo
11
Most read
12
Most read
13
Most read
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming With Example | Simplilearn
Multiple inheritance
What is Inheritance ?
Why do we use inheritance in C++?
Types of inheritance
Single inheritance
Modes of inheritance
Multi-level inheritance
Heirarchical inheritance
Hybrid inheritance
What’s in it for you ?
What is inheritance ?
Inheritance can be defined as a process in which objects of child
class acquires properties and characteristics from the parent
class.
In C++, OOPs concept inheritance is one of the most important
feature.
The class which inherits the properties is called the derived
class, and the class whose properties or characteristics are
inherited is called the base class.
Inherited
properties
Click here to watch the video
Why do we use inheritance ?
Inheritance is used because it helps in removing data
redundancy and increases the reusability of code.
To understand it, let’s suppose there are two classes two
wheeler and four wheeler both of the classes contains
similar functions like color() , brand(), Mileage().
Four wheeler Two wheeler
Color()
Brand()
Mileage()
Color()
Brand()
Mileage()
Why do we use inheritance ?
With Inheritance, we inherit both the classes from
one base class, i.e. class vehicle..
Now we have to write functions only once as both
the classes are now inherited from the base class.
Four wheeler
Color()
Brand()
Mileage()
Two wheeler
Color()
Brand()
Mileage()
Class vehicle
Color()
Brand()
Mileage()
Base class
Modes of inheritance
There are three modes of inheritance i.e Public, protected and
private.
Public mode: In this mode of inheritance the public members of the
base class remain public in the derived class, and same goes for
protected members.
Protected mode: In this mode the public and protected members of
the base class will become protected in the derived class.
Private mode: In Private mode protected and public members of
class will become private in the derived class.
Types of inheritance
There are various types of inheritance in C++ :
• Single inheritance
• Multiple inheritance
• Multi-level inheritance
• Heirarchical inheritance
• Hybrid inheritance
Single inheritance
In this type of inheritance, there is a single derived class
from a single base class.
Syntax:
Class derived_class : access_modifier Base_class
{
//body
};
Class Base_class
Class derived_class
Multiple inheritance
In this type of inheritance, the derived class is inherited from
more than one base class.
Syntax:
Class derived_class : access_modifier Base_class1 ,
access_modifier Base_class2
{
//body
};
Class
Base_class1
Class
derived_class
Class
Base_class2
Multi-level inheritance
In Multi-level inheritance, the derived class is inherited
from another derived class.
Syntax:
Class Base_class2 : access_modifier Base_class1
{
//body
};
Class derived_class : access_modifier Base_class2
{
//body
};
Class
Base_class1
Class
derived_class
Class
Base_class2
Heirarchical inheritance
If more than one class is inherited from the base class
then it is known as hierarchical inheritance.
Syntax:
Class derived_class1 : access_modifier Base_class
{
//body
};
Class derived_class2 : access_modifier Base_class
{
//body
};
Class derived_class3 : access_modifier Base_class
{
//body
};
Class
Base_class
Class
derived1
Class
derived2
Class
derived3
Hybrid inheritance
Hybrid inheritance is implemented by combining
more than one type of inheritance.
It can be said as the combination of both multilevel
and hierarchical inheritance.
Class
Base_class1
Class
derived_class2
Class
derived_class1
Class
derived_class3

More Related Content

What's hot (20)

PPTX
Packages in java
Elizabeth alexander
 
PPTX
Inheritance in c++
Paumil Patel
 
PPTX
Abstract class in c++
Sujan Mia
 
PPTX
Inheritance in OOPS
Ronak Chhajed
 
PPTX
Inheritance in java
Tech_MX
 
PPTX
oops concept in java | object oriented programming in java
CPD INDIA
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPTX
Java package
CS_GDRCST
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
Encapsulation
Githushan Gengaparam
 
PDF
Polymorphism in oop
MustafaIbrahimy
 
PPT
Class and object in C++
rprajat007
 
PPTX
Control statements in c
Sathish Narayanan
 
PPTX
Inheritance in c++
Vishal Patil
 
PDF
Arrays in Java
Naz Abdalla
 
PDF
Classes and Objects
yndaravind
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Virtual base class
Tech_MX
 
Packages in java
Elizabeth alexander
 
Inheritance in c++
Paumil Patel
 
Abstract class in c++
Sujan Mia
 
Inheritance in OOPS
Ronak Chhajed
 
Inheritance in java
Tech_MX
 
oops concept in java | object oriented programming in java
CPD INDIA
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Java package
CS_GDRCST
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Encapsulation
Githushan Gengaparam
 
Polymorphism in oop
MustafaIbrahimy
 
Class and object in C++
rprajat007
 
Control statements in c
Sathish Narayanan
 
Inheritance in c++
Vishal Patil
 
Arrays in Java
Naz Abdalla
 
Classes and Objects
yndaravind
 
07. Virtual Functions
Haresh Jaiswal
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Virtual base class
Tech_MX
 

Similar to C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming With Example | Simplilearn (20)

PPTX
Final presentation programming
haider ali
 
PPTX
Inheritance
Amit Dixit
 
PPTX
TYPES OF INHERITANCE CONCEPT IN C++.pptx
SPECIALISESPECIALISE
 
PDF
lecture 6.pdf
WaqarRaj1
 
PPTX
Inheritance
Munsif Ullah
 
PDF
UNIT 4.pdf.........................................
nikhithanikky1212
 
DOCX
UNIT 4.docx.........................................
nikhithanikky1212
 
PPTX
Object Oriented Design and Programming Unit-03
Sivakumar M
 
PDF
OOP Assign No.03(AP).pdf
Anant240318
 
PPTX
INHERITANCE-Oopc ppt-ta4
Ashutosh Makwana
 
PPTX
simple notes Unit 4-Inheritance (2).pptx
riyanahameed04
 
PPTX
Programming presentation
haider ali
 
PPTX
Inheritance
prabhat kumar
 
PPT
Inheritance in C++
Shweta Shah
 
PPT
10.Inheritance.ppt for oops programinggg
sanketkashyap2023
 
PPTX
inheritance
krishna partiwala
 
PPT
Inheritance, Object Oriented Programming
Arslan Waseem
 
PPTX
Introduction to Inheritance
Keshav Vaswani
 
PPTX
Inheritance in oops
Hirra Sultan
 
Final presentation programming
haider ali
 
Inheritance
Amit Dixit
 
TYPES OF INHERITANCE CONCEPT IN C++.pptx
SPECIALISESPECIALISE
 
lecture 6.pdf
WaqarRaj1
 
Inheritance
Munsif Ullah
 
UNIT 4.pdf.........................................
nikhithanikky1212
 
UNIT 4.docx.........................................
nikhithanikky1212
 
Object Oriented Design and Programming Unit-03
Sivakumar M
 
OOP Assign No.03(AP).pdf
Anant240318
 
INHERITANCE-Oopc ppt-ta4
Ashutosh Makwana
 
simple notes Unit 4-Inheritance (2).pptx
riyanahameed04
 
Programming presentation
haider ali
 
Inheritance
prabhat kumar
 
Inheritance in C++
Shweta Shah
 
10.Inheritance.ppt for oops programinggg
sanketkashyap2023
 
inheritance
krishna partiwala
 
Inheritance, Object Oriented Programming
Arslan Waseem
 
Introduction to Inheritance
Keshav Vaswani
 
Inheritance in oops
Hirra Sultan
 
Ad

More from Simplilearn (20)

PPTX
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
PPTX
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
PPTX
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
PPTX
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
PPTX
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
PPTX
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
PPTX
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
PPTX
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
PPTX
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
PPTX
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
PPTX
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
PPTX
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
PPTX
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
PPTX
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
PPTX
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
PPTX
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Ad

Recently uploaded (20)

PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 

C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming With Example | Simplilearn

  • 2. Multiple inheritance What is Inheritance ? Why do we use inheritance in C++? Types of inheritance Single inheritance Modes of inheritance Multi-level inheritance Heirarchical inheritance Hybrid inheritance What’s in it for you ?
  • 3. What is inheritance ? Inheritance can be defined as a process in which objects of child class acquires properties and characteristics from the parent class. In C++, OOPs concept inheritance is one of the most important feature. The class which inherits the properties is called the derived class, and the class whose properties or characteristics are inherited is called the base class. Inherited properties
  • 4. Click here to watch the video
  • 5. Why do we use inheritance ? Inheritance is used because it helps in removing data redundancy and increases the reusability of code. To understand it, let’s suppose there are two classes two wheeler and four wheeler both of the classes contains similar functions like color() , brand(), Mileage(). Four wheeler Two wheeler Color() Brand() Mileage() Color() Brand() Mileage()
  • 6. Why do we use inheritance ? With Inheritance, we inherit both the classes from one base class, i.e. class vehicle.. Now we have to write functions only once as both the classes are now inherited from the base class. Four wheeler Color() Brand() Mileage() Two wheeler Color() Brand() Mileage() Class vehicle Color() Brand() Mileage() Base class
  • 7. Modes of inheritance There are three modes of inheritance i.e Public, protected and private. Public mode: In this mode of inheritance the public members of the base class remain public in the derived class, and same goes for protected members. Protected mode: In this mode the public and protected members of the base class will become protected in the derived class. Private mode: In Private mode protected and public members of class will become private in the derived class.
  • 8. Types of inheritance There are various types of inheritance in C++ : • Single inheritance • Multiple inheritance • Multi-level inheritance • Heirarchical inheritance • Hybrid inheritance
  • 9. Single inheritance In this type of inheritance, there is a single derived class from a single base class. Syntax: Class derived_class : access_modifier Base_class { //body }; Class Base_class Class derived_class
  • 10. Multiple inheritance In this type of inheritance, the derived class is inherited from more than one base class. Syntax: Class derived_class : access_modifier Base_class1 , access_modifier Base_class2 { //body }; Class Base_class1 Class derived_class Class Base_class2
  • 11. Multi-level inheritance In Multi-level inheritance, the derived class is inherited from another derived class. Syntax: Class Base_class2 : access_modifier Base_class1 { //body }; Class derived_class : access_modifier Base_class2 { //body }; Class Base_class1 Class derived_class Class Base_class2
  • 12. Heirarchical inheritance If more than one class is inherited from the base class then it is known as hierarchical inheritance. Syntax: Class derived_class1 : access_modifier Base_class { //body }; Class derived_class2 : access_modifier Base_class { //body }; Class derived_class3 : access_modifier Base_class { //body }; Class Base_class Class derived1 Class derived2 Class derived3
  • 13. Hybrid inheritance Hybrid inheritance is implemented by combining more than one type of inheritance. It can be said as the combination of both multilevel and hierarchical inheritance. Class Base_class1 Class derived_class2 Class derived_class1 Class derived_class3