SlideShare a Scribd company logo
1 of 14
P R E P A R E D B Y :
S H R E Y A S S
K E S H A V V
U N D E R T H E G U I D A N C E O F :
M R S . A R C H A N A S A I D
S E C O M P , A I S S M S โ€™ I O I T , P U N E
INHERITANCE
BASICS
๏‚— Object Oriented Programming has different unique
and important features like classes, objects,
inheritance and polymorphism.
๏‚— Inheritance is the concept using which one class
can derive the properties of another class.
๏‚— This provides reusability in the program code.
๏‚— Due to this, cost of program development is
reduced.
EXAMPLE
๏‚— Car is a classification of Four Wheeler. Here Car acquires
the properties of a four-wheeler. Other classifications could
be a jeep, tempo, van etc. Four Wheeler defines a class of
vehicles that have four wheels, and specific range of engine
power, load carrying capacity etc. Car (termed as a sub-
class) acquires these properties from Four Wheeler (termed
as a super-class), and has some specific properties, which
are different from other classifications of Four Wheeler,
such as luxury, comfort, shape, size, usage etc.
๏‚— A car can have further classification such as an open car,
small car, big car etc, which will acquire the properties from
both Four Wheeler and Car, but will still have some specific
properties. This way the level of hierarchy can be extended
to any level.
BASE CLASS AND DERIVED CLASS
๏‚— Base class is the class whose properties are
inherited by another class.
๏‚— Derived class is the class which inherits the
properties of another class.
๏‚— Base class is also known as parent class or old
class.
๏‚— Derived class is also known as child class or new
class.
๏‚— A derived class inherit the properties of base class
and can have its own extra properties as well.
ACCESS SPECIFIERS
๏‚— Access specifiers specify the scope of the data declared in them, i.e. they
tell us in which all parts of the program can those data members or
member functions be accessed.
๏‚— C++ has provided us with 3 access specifiers, namely private, protected
and public.
๏‚— Members declared as private in a class can only be accessed by the
methods of the same class which are declared in public section.
๏‚— Members declared as protected are the same as private members. The
only difference is that protected members can be inherited in adjacent
derived classes whereas private members are not inherited at all.
๏‚— Members declared as public can be accessed anywhere in the program.
MODES OF INHERITANCE
๏‚— A class(derived class) can derive the properties of another class(base
class) in 3 modes: private, protected and public.
๏‚— If the derived class inherits in private mode, both the protected as well
as the public members of the base class become the private members of
the derived class.
๏‚— If the derived class inherits in protected mode, both the protected and
the public members of the base class become the protected members of
the derived class.
๏‚— If the derived class inherits in public mode, then the protected
members of the base class will become the protected members of the
derived class, whereas the public members of the base class will
become the public members of the derived class.
๏‚— Private members of the base class will not get inherited at any cost.
TYPES OF INHERITANCE
๏‚— There are 5 types of inheritance:
๏‚— 1. Single Inheritance
๏‚— 2. Multiple Inheritance
๏‚— 3. Multilevel Inheritance
๏‚— 4. Hierarchical Inheritance
๏‚— 5. Hybrid Inheritance
SINGLE INHERITANCE
๏‚— In this type of inheritance, a single derived class
inherits the properties of a single base class.
๏‚— In the above example, B is the derived class
inheriting the properties of base class A.
A
B
MULTIPLE INHERITANCE
๏‚— In this type of inheritance, a single derived class
inherits the properties of more than one base classes.
๏‚— In the above example, C is a derived class inheriting
from two base classes, A and B.
A B
C
MULTILEVEL INHERITANCE
๏‚— In this type of inheritance, a derived class acts as a
base class to another class.
๏‚— In the above example, B is a derived class inheriting from
base class A, but B also acts as a base class to class C.
A
B
C
HIERARCHICAL INHERITANCE
๏‚— In this type of inheritance, more than one derived
classes inherit the properties of a single base class.
๏‚— In the above example, B and C are two different
derived classes inheriting from a single base class A.
A
B C
HYBRID INHERITANCE
๏‚— It is a mixture of two or more types of inheritance.
๏‚— In the above example, classes B and C inherit from base
class A(hierarchical inheritance) and further, class D
inherits from classes B and C(multiple inheritance). So, it
becomes hybrid inheritance.
A
D
B C
ORDER OF CALLING CONSTRUCTORS AND
DESTRUCTORS
๏‚— Order of calling constructors and destructors in
inheritance is as follows:
๏‚— First, constructor of base class is invoked.
๏‚— Then, constructor of derived class is invoked.
๏‚— After that, destructor of derived class is invoked.
๏‚— At last, destructor of base class is invoked.
THE END
๏‚—THANK YOU!

More Related Content

What's hot

Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Gajendra Singh Thakur
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Paumil Patel
ย 
Inheritance
InheritanceInheritance
Inheritancepoonam.rwalia
ย 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingArslan Waseem
ย 
Inheritance
InheritanceInheritance
InheritancePadma Kannan
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vishal Patil
ย 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oopsHirra Sultan
ย 
EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++Nikunj Patel
ย 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.MASQ Technologies
ย 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...cprogrammings
ย 
Inheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaMananPasricha
ย 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Sujan Mia
ย 
Inheritance
InheritanceInheritance
InheritanceMustafa Khan
ย 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++tayyaba nawaz
ย 

What's hot (20)

Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Inheritance in c++theory
Inheritance in c++theoryInheritance in c++theory
Inheritance in c++theory
ย 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
ย 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
ย 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
ย 
EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
ย 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
ย 
inheritance c++
inheritance c++inheritance c++
inheritance c++
ย 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
ย 
Inheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan Pasricha
ย 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
ย 

Viewers also liked

Down Syndrome.ppt
Down Syndrome.pptDown Syndrome.ppt
Down Syndrome.pptShama
ย 
Down syndrome presentation
Down syndrome   presentationDown syndrome   presentation
Down syndrome presentationEuridiki
ย 
Down syndrome Characteristics, Diagnosis, Prognosis, Treatment
Down syndrome Characteristics, Diagnosis, Prognosis, TreatmentDown syndrome Characteristics, Diagnosis, Prognosis, Treatment
Down syndrome Characteristics, Diagnosis, Prognosis, TreatmentYuti Doshi
ย 
congenital anomalies of renal system
congenital anomalies of renal systemcongenital anomalies of renal system
congenital anomalies of renal systemRia Saira
ย 

Viewers also liked (7)

Genitics
GeniticsGenitics
Genitics
ย 
Types of Inheritance
Types of InheritanceTypes of Inheritance
Types of Inheritance
ย 
Down Syndrome.ppt
Down Syndrome.pptDown Syndrome.ppt
Down Syndrome.ppt
ย 
What Is Down Syndrome?
What Is Down Syndrome?What Is Down Syndrome?
What Is Down Syndrome?
ย 
Down syndrome presentation
Down syndrome   presentationDown syndrome   presentation
Down syndrome presentation
ย 
Down syndrome Characteristics, Diagnosis, Prognosis, Treatment
Down syndrome Characteristics, Diagnosis, Prognosis, TreatmentDown syndrome Characteristics, Diagnosis, Prognosis, Treatment
Down syndrome Characteristics, Diagnosis, Prognosis, Treatment
ย 
congenital anomalies of renal system
congenital anomalies of renal systemcongenital anomalies of renal system
congenital anomalies of renal system
ย 

Similar to Introduction to Inheritance

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.pptclassall
ย 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...Simplilearn
ย 
Ritik (inheritance.cpp)
Ritik (inheritance.cpp)Ritik (inheritance.cpp)
Ritik (inheritance.cpp)RitikAhlawat1
ย 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdfWaqarRaj1
ย 
Inheritance (with classifications)
Inheritance (with classifications)Inheritance (with classifications)
Inheritance (with classifications)Redwan Islam
ย 
Final presentation programming
Final presentation programmingFinal presentation programming
Final presentation programminghaider ali
ย 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.pptLadallaRajKumar
ย 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++RAJ KUMAR
ย 
Inheritance
Inheritance Inheritance
Inheritance sourav verma
ย 
Inheritance
InheritanceInheritance
Inheritanceprabhat kumar
ย 
Chapter25 inheritance-i
Chapter25 inheritance-iChapter25 inheritance-i
Chapter25 inheritance-iDeepak Singh
ย 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)Pooja Bhojwani
ย 
INHERITANCE
INHERITANCEINHERITANCE
INHERITANCERohitK71
ย 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance pptNivegeetha
ย 
Programming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptxProgramming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptxDilanAlmsa
ย 
Inheritance and Polymorphism in Oops
Inheritance and Polymorphism in OopsInheritance and Polymorphism in Oops
Inheritance and Polymorphism in OopsLalfakawmaKh
ย 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In JavaMD SALEEM QAISAR
ย 

Similar to Introduction to Inheritance (20)

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
ย 
Ritik (inheritance.cpp)
Ritik (inheritance.cpp)Ritik (inheritance.cpp)
Ritik (inheritance.cpp)
ย 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
ย 
Inheritance (with classifications)
Inheritance (with classifications)Inheritance (with classifications)
Inheritance (with classifications)
ย 
Final presentation programming
Final presentation programmingFinal presentation programming
Final presentation programming
ย 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
ย 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
ย 
Inheritance
Inheritance Inheritance
Inheritance
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Chapter25 inheritance-i
Chapter25 inheritance-iChapter25 inheritance-i
Chapter25 inheritance-i
ย 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
INHERITANCE
INHERITANCEINHERITANCE
INHERITANCE
ย 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
ย 
Programming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptxProgramming Lesson by Slidesgo.pptx
Programming Lesson by Slidesgo.pptx
ย 
Inheritance and Polymorphism in Oops
Inheritance and Polymorphism in OopsInheritance and Polymorphism in Oops
Inheritance and Polymorphism in Oops
ย 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 

Recently uploaded

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
ย 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
ย 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
ย 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
ย 
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
ย 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
ย 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
ย 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
ย 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
ย 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
ย 
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoordharasingh5698
ย 

Recently uploaded (20)

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
ย 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
ย 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
ย 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
ย 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
ย 
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Netaji Nagar, Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ย 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
ย 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
ย 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
ย 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
ย 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ย 
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor ๐Ÿ“ฑ {7001035870} VIP Escorts chittoor
ย 

Introduction to Inheritance

  • 1. P R E P A R E D B Y : S H R E Y A S S K E S H A V V U N D E R T H E G U I D A N C E O F : M R S . A R C H A N A S A I D S E C O M P , A I S S M S โ€™ I O I T , P U N E INHERITANCE
  • 2. BASICS ๏‚— Object Oriented Programming has different unique and important features like classes, objects, inheritance and polymorphism. ๏‚— Inheritance is the concept using which one class can derive the properties of another class. ๏‚— This provides reusability in the program code. ๏‚— Due to this, cost of program development is reduced.
  • 3. EXAMPLE ๏‚— Car is a classification of Four Wheeler. Here Car acquires the properties of a four-wheeler. Other classifications could be a jeep, tempo, van etc. Four Wheeler defines a class of vehicles that have four wheels, and specific range of engine power, load carrying capacity etc. Car (termed as a sub- class) acquires these properties from Four Wheeler (termed as a super-class), and has some specific properties, which are different from other classifications of Four Wheeler, such as luxury, comfort, shape, size, usage etc. ๏‚— A car can have further classification such as an open car, small car, big car etc, which will acquire the properties from both Four Wheeler and Car, but will still have some specific properties. This way the level of hierarchy can be extended to any level.
  • 4. BASE CLASS AND DERIVED CLASS ๏‚— Base class is the class whose properties are inherited by another class. ๏‚— Derived class is the class which inherits the properties of another class. ๏‚— Base class is also known as parent class or old class. ๏‚— Derived class is also known as child class or new class. ๏‚— A derived class inherit the properties of base class and can have its own extra properties as well.
  • 5. ACCESS SPECIFIERS ๏‚— Access specifiers specify the scope of the data declared in them, i.e. they tell us in which all parts of the program can those data members or member functions be accessed. ๏‚— C++ has provided us with 3 access specifiers, namely private, protected and public. ๏‚— Members declared as private in a class can only be accessed by the methods of the same class which are declared in public section. ๏‚— Members declared as protected are the same as private members. The only difference is that protected members can be inherited in adjacent derived classes whereas private members are not inherited at all. ๏‚— Members declared as public can be accessed anywhere in the program.
  • 6. MODES OF INHERITANCE ๏‚— A class(derived class) can derive the properties of another class(base class) in 3 modes: private, protected and public. ๏‚— If the derived class inherits in private mode, both the protected as well as the public members of the base class become the private members of the derived class. ๏‚— If the derived class inherits in protected mode, both the protected and the public members of the base class become the protected members of the derived class. ๏‚— If the derived class inherits in public mode, then the protected members of the base class will become the protected members of the derived class, whereas the public members of the base class will become the public members of the derived class. ๏‚— Private members of the base class will not get inherited at any cost.
  • 7. TYPES OF INHERITANCE ๏‚— There are 5 types of inheritance: ๏‚— 1. Single Inheritance ๏‚— 2. Multiple Inheritance ๏‚— 3. Multilevel Inheritance ๏‚— 4. Hierarchical Inheritance ๏‚— 5. Hybrid Inheritance
  • 8. SINGLE INHERITANCE ๏‚— In this type of inheritance, a single derived class inherits the properties of a single base class. ๏‚— In the above example, B is the derived class inheriting the properties of base class A. A B
  • 9. MULTIPLE INHERITANCE ๏‚— In this type of inheritance, a single derived class inherits the properties of more than one base classes. ๏‚— In the above example, C is a derived class inheriting from two base classes, A and B. A B C
  • 10. MULTILEVEL INHERITANCE ๏‚— In this type of inheritance, a derived class acts as a base class to another class. ๏‚— In the above example, B is a derived class inheriting from base class A, but B also acts as a base class to class C. A B C
  • 11. HIERARCHICAL INHERITANCE ๏‚— In this type of inheritance, more than one derived classes inherit the properties of a single base class. ๏‚— In the above example, B and C are two different derived classes inheriting from a single base class A. A B C
  • 12. HYBRID INHERITANCE ๏‚— It is a mixture of two or more types of inheritance. ๏‚— In the above example, classes B and C inherit from base class A(hierarchical inheritance) and further, class D inherits from classes B and C(multiple inheritance). So, it becomes hybrid inheritance. A D B C
  • 13. ORDER OF CALLING CONSTRUCTORS AND DESTRUCTORS ๏‚— Order of calling constructors and destructors in inheritance is as follows: ๏‚— First, constructor of base class is invoked. ๏‚— Then, constructor of derived class is invoked. ๏‚— After that, destructor of derived class is invoked. ๏‚— At last, destructor of base class is invoked.