SlideShare a Scribd company logo
7
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

PPTX
Multiple inheritance in c++
Sujan Mia
 
PPTX
Inheritance In C++ (Object Oriented Programming)
Gajendra Singh Thakur
 
PPTX
Inheritance in c++
Paumil Patel
 
PPTX
Inheritance in C++
Laxman Puri
 
PPTX
OOPS Basics With Example
Thooyavan Venkatachalam
 
PPTX
Inheritance in Object Oriented Programming
Ashita Agrawal
 
PPTX
Polymorphism in C++
Rabin BK
 
PPTX
Characteristics of OOPS
abhishek kumar
 
Multiple inheritance in c++
Sujan Mia
 
Inheritance In C++ (Object Oriented Programming)
Gajendra Singh Thakur
 
Inheritance in c++
Paumil Patel
 
Inheritance in C++
Laxman Puri
 
OOPS Basics With Example
Thooyavan Venkatachalam
 
Inheritance in Object Oriented Programming
Ashita Agrawal
 
Polymorphism in C++
Rabin BK
 
Characteristics of OOPS
abhishek kumar
 

What's hot (20)

PPTX
Inheritance in c++
Vineeta Garg
 
PPTX
Inheritance in JAVA PPT
Pooja Jaiswal
 
PPTX
Virtual base class
Tech_MX
 
PPTX
Inheritance in java
Tech_MX
 
PDF
C++ OOPS Concept
Boopathi K
 
PPTX
Super keyword in java
Hitesh Kumar
 
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
PPTX
This keyword in java
Hitesh Kumar
 
PPT
friend function(c++)
Ritika Sharma
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPT
Operator Overloading
Nilesh Dalvi
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
Polymorphism in c++(ppt)
Sanjit Shaw
 
PPTX
Java packages
BHUVIJAYAVELU
 
PPTX
Inheritance in java
RahulAnanda1
 
PPTX
class and objects
Payel Guria
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPT
Applet life cycle
myrajendra
 
PPTX
Inheritance
Tech_MX
 
PPTX
Interface in java
PhD Research Scholar
 
Inheritance in c++
Vineeta Garg
 
Inheritance in JAVA PPT
Pooja Jaiswal
 
Virtual base class
Tech_MX
 
Inheritance in java
Tech_MX
 
C++ OOPS Concept
Boopathi K
 
Super keyword in java
Hitesh Kumar
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
This keyword in java
Hitesh Kumar
 
friend function(c++)
Ritika Sharma
 
classes and objects in C++
HalaiHansaika
 
Operator Overloading
Nilesh Dalvi
 
Pure virtual function and abstract class
Amit Trivedi
 
Polymorphism in c++(ppt)
Sanjit Shaw
 
Java packages
BHUVIJAYAVELU
 
Inheritance in java
RahulAnanda1
 
class and objects
Payel Guria
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Applet life cycle
myrajendra
 
Inheritance
Tech_MX
 
Interface in java
PhD Research Scholar
 
Ad

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
 
PPTX
Inheritance in c++
Vishal Patil
 
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
 
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 in c++
Vishal Patil
 
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
 
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
 

Recently uploaded (20)

PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
PPTX
Trends in pediatric nursing .pptx
AneetaSharma15
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
Trends in pediatric nursing .pptx
AneetaSharma15
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 

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