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

PPS
Inheritance
PPT
Inheritance
PPTX
Inheritance in OOPS
PPTX
Single inheritance
PPT
Inheritance
PPTX
Inheritance in c++ part1
PPTX
inheritance
PPTX
Inheritance in Object Oriented Programming
Inheritance
Inheritance
Inheritance in OOPS
Single inheritance
Inheritance
Inheritance in c++ part1
inheritance
Inheritance in Object Oriented Programming

What's hot (20)

PPTX
Inheritance In C++ (Object Oriented Programming)
PPTX
Inheritance in c++
PPT
Inheritance
PPTX
Inheritance in c++theory
PPT
Inheritance, Object Oriented Programming
PPSX
PDF
Inheritance
PPTX
Inheritance in c++
PPTX
Inheritance in c++
PPTX
Inheritance in oops
PPTX
EASY TO LEARN INHERITANCE IN C++
PPT
Inheritance
PPT
Inheritance OOP Concept in C++.
PPTX
inheritance c++
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
PPTX
Inheritance in c++ by Manan Pasricha
PPTX
Multiple inheritance in c++
PPT
Inheritance
PPTX
inheritance in C++
Inheritance In C++ (Object Oriented Programming)
Inheritance in c++
Inheritance
Inheritance in c++theory
Inheritance, Object Oriented Programming
Inheritance
Inheritance in c++
Inheritance in c++
Inheritance in oops
EASY TO LEARN INHERITANCE IN C++
Inheritance
Inheritance OOP Concept in C++.
inheritance c++
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ by Manan Pasricha
Multiple inheritance in c++
Inheritance
inheritance in C++
Ad

Viewers also liked (6)

PPTX
Types of Inheritance
PPTX
PPTX
Down syndrome presentation
PPTX
Down syndrome Characteristics, Diagnosis, Prognosis, Treatment
PPSX
congenital anomalies of renal system
Types of Inheritance
Down syndrome presentation
Down syndrome Characteristics, Diagnosis, Prognosis, Treatment
congenital anomalies of renal system
Ad

Similar to Introduction to Inheritance (20)

PPT
E -COMMERCE.ppt
PPTX
Inheritance
PPTX
TYPES OF INHERITANCE CONCEPT IN C++.pptx
PPTX
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
PPTX
Ritik (inheritance.cpp)
PDF
lecture 6.pdf
PPTX
Inheritance (with classifications)
PPTX
Final presentation programming
PPT
11 Inheritance.ppt
PPTX
Inheritance in C++ (Programming Fundamentals)
PPT
Inheritance in C++
PPTX
Inheritance
PPTX
Inheritance
PDF
Chapter25 inheritance-i
PPTX
Java(inheritance)
PDF
Inheritance
PDF
INHERITANCE
PPTX
Inheritance in Java - An Introduction & types
PPTX
Inheritance ppt
PPTX
Programming Lesson by Slidesgo.pptx
E -COMMERCE.ppt
Inheritance
TYPES OF INHERITANCE CONCEPT IN C++.pptx
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
Ritik (inheritance.cpp)
lecture 6.pdf
Inheritance (with classifications)
Final presentation programming
11 Inheritance.ppt
Inheritance in C++ (Programming Fundamentals)
Inheritance in C++
Inheritance
Inheritance
Chapter25 inheritance-i
Java(inheritance)
Inheritance
INHERITANCE
Inheritance in Java - An Introduction & types
Inheritance ppt
Programming Lesson by Slidesgo.pptx

Recently uploaded (20)

PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
additive manufacturing of ss316l using mig welding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Well-logging-methods_new................
PDF
composite construction of structures.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Geodesy 1.pptx...............................................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
737-MAX_SRG.pdf student reference guides
Automation-in-Manufacturing-Chapter-Introduction.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
III.4.1.2_The_Space_Environment.p pdffdf
OOP with Java - Java Introduction (Basics)
additive manufacturing of ss316l using mig welding
Embodied AI: Ushering in the Next Era of Intelligent Systems
Well-logging-methods_new................
composite construction of structures.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Geodesy 1.pptx...............................................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
UNIT-1 - COAL BASED THERMAL POWER PLANTS
bas. eng. economics group 4 presentation 1.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Safety Seminar civil to be ensured for safe working.
737-MAX_SRG.pdf student reference guides

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.