SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
When a class is derived from a class which is also
derived from another class, i.e. a class having more
than one parent classes, such inheritance is called
Multilevel Inheritance
Child class
The class which inherits
the properties of another class is
called Derived or Child or Sub
class
Parent class
The class whose properties
are inherited is called Base or
Parent or Super class.
Syntax of Multilevel Inheritance
class A //Base class
{ ---------
--------- //body of class A
---------
};
class B : public A //B derived from class A
{ ----------
--------- //body of class B
----------
};
Syntax of Multilevel Inheritance
class C : public B //C derived from class B
{ ----------
--------- //body of class C
----------
};
//This process can be extended to any number of levels.
Example of Multilevel Inheritance in C++
#include<iostream>
using namespace std;
class B1
{
protected:
float m, n;
public:
assign (float x, float y)
{
m = x;
n = y;
}
}; //end base class B1
Example of Multilevel Inheritance in C++
class B2 : public B1
{
public:
sum()
{
cout<<"Sum of "<<m<<"and"<<n<<"="<<m+n<<endl;
}
}; //end derived class B2
class D1 : public B2
{
public:
product()
{
cout<<"Product of "<<m<<"and"<<n<<"="<<m*n<<endl;
}
}; //end derived class D1
Example of Multilevel Inheritance in C++
main()
{
D1 x;
x .assign (10, 2);
x .sum ();
x .product();
return 0;
}
Output of Program
• Sum of 10 and 2 = 12
• Product of 10 and 2 = 20
Diagrammatically
Natural inheritence
Multi level inheritence

More Related Content

What's hot (20)

PPTX
Constructors and Destructor in C++
International Institute of Information Technology (I²IT)
 
PPT
Final keyword in java
Lovely Professional University
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
Inheritance in c++
Vineeta Garg
 
PPT
Files in c++ ppt
Kumar
 
PPTX
Function in c program
umesh patil
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPTX
Abstract class in c++
Sujan Mia
 
PPTX
Inheritance in java
RahulAnanda1
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
Dynamic memory allocation
Viji B
 
PDF
Constructor and Destructor
Kamal Acharya
 
PPTX
Single inheritance
Äkshäý M S
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
Access specifier
zindadili
 
PDF
Function overloading ppt
Prof. Dr. K. Adisesha
 
PDF
Exception handling
Pranali Chaudhari
 
PPTX
Inheritance in OOPS
Ronak Chhajed
 
PPTX
Constructor ppt
Vinod Kumar
 
Final keyword in java
Lovely Professional University
 
Java interfaces
Raja Sekhar
 
Inheritance in c++
Vineeta Garg
 
Files in c++ ppt
Kumar
 
Function in c program
umesh patil
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Abstract class in c++
Sujan Mia
 
Inheritance in java
RahulAnanda1
 
Constructor in java
Pavith Gunasekara
 
Dynamic memory allocation
Viji B
 
Constructor and Destructor
Kamal Acharya
 
Single inheritance
Äkshäý M S
 
Pure virtual function and abstract class
Amit Trivedi
 
Access specifier
zindadili
 
Function overloading ppt
Prof. Dr. K. Adisesha
 
Exception handling
Pranali Chaudhari
 
Inheritance in OOPS
Ronak Chhajed
 
Constructor ppt
Vinod Kumar
 

Similar to Multi level inheritence (20)

PPT
E -COMMERCE.ppt
classall
 
PPTX
Inheritance
prabhat kumar
 
PPTX
Inheritance
SangeethaSasi1
 
DOCX
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
PPT
Module 4 Effect of Reuse on using Inheritance.ppt
ramlingams
 
PPTX
Inheritance (with classifications)
Redwan Islam
 
PPTX
iheritence.pptx
RijuMandal11
 
PPTX
Ritik (inheritance.cpp)
RitikAhlawat1
 
PPTX
Week 8 - OOP Inheritance11111111111.pptx
NajamUlHassan73
 
PPTX
Inheritance
disha singh
 
PPTX
Programming Lesson by Slidesgo.pptx
DilanAlmsa
 
PPT
week14 (1).ppt
amal68766
 
PPTX
Inheritance
prashant prath
 
PPTX
types of inheritancec , inheritance ,data structures and algorithim oresentat...
starkdevil15
 
PDF
lecture 6.pdf
WaqarRaj1
 
PPTX
Inheritance.pptx
preetirawat242004
 
PPTX
Inheritance in c++theory
ProfSonaliGholveDoif
 
PPT
Inheritance.ppt
JP2B1197685ARamSaiPM
 
PPTX
inheritance
krishna partiwala
 
PDF
OOP Assign No.03(AP).pdf
Anant240318
 
E -COMMERCE.ppt
classall
 
Inheritance
prabhat kumar
 
Inheritance
SangeethaSasi1
 
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
Module 4 Effect of Reuse on using Inheritance.ppt
ramlingams
 
Inheritance (with classifications)
Redwan Islam
 
iheritence.pptx
RijuMandal11
 
Ritik (inheritance.cpp)
RitikAhlawat1
 
Week 8 - OOP Inheritance11111111111.pptx
NajamUlHassan73
 
Inheritance
disha singh
 
Programming Lesson by Slidesgo.pptx
DilanAlmsa
 
week14 (1).ppt
amal68766
 
Inheritance
prashant prath
 
types of inheritancec , inheritance ,data structures and algorithim oresentat...
starkdevil15
 
lecture 6.pdf
WaqarRaj1
 
Inheritance.pptx
preetirawat242004
 
Inheritance in c++theory
ProfSonaliGholveDoif
 
Inheritance.ppt
JP2B1197685ARamSaiPM
 
inheritance
krishna partiwala
 
OOP Assign No.03(AP).pdf
Anant240318
 
Ad

Recently uploaded (20)

PPTX
quantum computing transition from classical mechanics.pptx
gvlbcy
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
PDF
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PPTX
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PPTX
Precedence and Associativity in C prog. language
Mahendra Dheer
 
PDF
All chapters of Strength of materials.ppt
girmabiniyam1234
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
quantum computing transition from classical mechanics.pptx
gvlbcy
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
4 Tier Teamcenter Installation part1.pdf
VnyKumar1
 
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Inventory management chapter in automation and robotics.
atisht0104
 
Information Retrieval and Extraction - Module 7
premSankar19
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
Precedence and Associativity in C prog. language
Mahendra Dheer
 
All chapters of Strength of materials.ppt
girmabiniyam1234
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Ad

Multi level inheritence

  • 1. When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent classes, such inheritance is called Multilevel Inheritance
  • 2. Child class The class which inherits the properties of another class is called Derived or Child or Sub class Parent class The class whose properties are inherited is called Base or Parent or Super class.
  • 3. Syntax of Multilevel Inheritance class A //Base class { --------- --------- //body of class A --------- }; class B : public A //B derived from class A { ---------- --------- //body of class B ---------- };
  • 4. Syntax of Multilevel Inheritance class C : public B //C derived from class B { ---------- --------- //body of class C ---------- }; //This process can be extended to any number of levels.
  • 5. Example of Multilevel Inheritance in C++ #include<iostream> using namespace std; class B1 { protected: float m, n; public: assign (float x, float y) { m = x; n = y; } }; //end base class B1
  • 6. Example of Multilevel Inheritance in C++ class B2 : public B1 { public: sum() { cout<<"Sum of "<<m<<"and"<<n<<"="<<m+n<<endl; } }; //end derived class B2 class D1 : public B2 { public: product() { cout<<"Product of "<<m<<"and"<<n<<"="<<m*n<<endl; } }; //end derived class D1
  • 7. Example of Multilevel Inheritance in C++ main() { D1 x; x .assign (10, 2); x .sum (); x .product(); return 0; }
  • 8. Output of Program • Sum of 10 and 2 = 12 • Product of 10 and 2 = 20