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
Polymorphism In c++
Vishesh Jha
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Inheritance in c++
Vishal Patil
 
PPT
Data types
myrajendra
 
PPTX
Inheritance in c++
Vineeta Garg
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPTX
Member Function in C++
NikitaKaur10
 
ODP
OOP java
xball977
 
PPTX
class and objects
Payel Guria
 
PPTX
Constructors and Destructor in C++
International Institute of Information Technology (I²IT)
 
PPTX
Polymorphism in c++(ppt)
Sanjit Shaw
 
PPTX
Inheritance in OOPS
Ronak Chhajed
 
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
PPTX
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
PPTX
Exception Handling in object oriented programming using C++
Janki Shah
 
PPT
Control structures in C++ Programming Language
Ahmad Idrees
 
PPTX
Super keyword in java
Hitesh Kumar
 
PDF
Operator overloading
Pranali Chaudhari
 
PPTX
Polymorphism in java
Elizabeth alexander
 
PPTX
OOPs in Java
Ranjith Sekar
 
Polymorphism In c++
Vishesh Jha
 
07. Virtual Functions
Haresh Jaiswal
 
Inheritance in c++
Vishal Patil
 
Data types
myrajendra
 
Inheritance in c++
Vineeta Garg
 
classes and objects in C++
HalaiHansaika
 
Member Function in C++
NikitaKaur10
 
OOP java
xball977
 
class and objects
Payel Guria
 
Polymorphism in c++(ppt)
Sanjit Shaw
 
Inheritance in OOPS
Ronak Chhajed
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Exception Handling in object oriented programming using C++
Janki Shah
 
Control structures in C++ Programming Language
Ahmad Idrees
 
Super keyword in java
Hitesh Kumar
 
Operator overloading
Pranali Chaudhari
 
Polymorphism in java
Elizabeth alexander
 
OOPs in Java
Ranjith Sekar
 

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

PPTX
Inheritance in c++ by Manan Pasricha
MananPasricha
 
PPT
Inheritance.ppt
JP2B1197685ARamSaiPM
 
PPTX
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
DOCX
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
PDF
Inheritance
Prof. Dr. K. Adisesha
 
PPTX
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
PDF
INHERITANCE
RohitK71
 
PPT
Inheritance and its types explained.ppt
SarthakKumar93
 
PPTX
Inheritance in C++ (Programming Fundamentals)
Home
 
PPTX
Inheritance
zindadili
 
PPTX
TYPES OF INHERITANCE CONCEPT IN C++.pptx
SPECIALISESPECIALISE
 
PPTX
Inheritance
SangeethaSasi1
 
PPTX
Inheritance
prabhat kumar
 
PPSX
Inheritance and Polymorphism in Oops
LalfakawmaKh
 
PDF
lecture 6.pdf
WaqarRaj1
 
PPT
6 Inheritance
Praveen M Jigajinni
 
PDF
inheritance-16031525566nbhij56604452.pdf
kashafishfaq21
 
PPT
Lec5.ppt
CharlesAsiedu4
 
PPT
Inheritance in C++
Shweta Shah
 
PPT
Inheritance
Aadhi Aadhithya
 
Inheritance in c++ by Manan Pasricha
MananPasricha
 
Inheritance.ppt
JP2B1197685ARamSaiPM
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
INHERITANCE
RohitK71
 
Inheritance and its types explained.ppt
SarthakKumar93
 
Inheritance in C++ (Programming Fundamentals)
Home
 
Inheritance
zindadili
 
TYPES OF INHERITANCE CONCEPT IN C++.pptx
SPECIALISESPECIALISE
 
Inheritance
SangeethaSasi1
 
Inheritance
prabhat kumar
 
Inheritance and Polymorphism in Oops
LalfakawmaKh
 
lecture 6.pdf
WaqarRaj1
 
6 Inheritance
Praveen M Jigajinni
 
inheritance-16031525566nbhij56604452.pdf
kashafishfaq21
 
Lec5.ppt
CharlesAsiedu4
 
Inheritance in C++
Shweta Shah
 
Inheritance
Aadhi Aadhithya
 
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)

PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 

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