SlideShare uma empresa Scribd logo
1 de 21
Inheritance
Ronak Chhajed
What is Inheritance ?
Inheritance is a relationship between two or more
classes where derived class inherits properties of pre-
existing (base) classes.
Base Class: It is the class whose properties are inherited
by another class. It is also called Super Class or Parent
Class.
Derived Class: It is the class that inherit properties from
base class(es). It is also called Sub Class or Child Class.
Concept of
Inheritance
Base Class
Property A
Property B
Property C
Property D
Property C
Property B
Property A
Derived
Class
Defined in
Derived Class
Defined in
Base Class
But accessible
from Derived
Class
Defining Derived Classes
A derived class can be defined by specifying its relationship
with the base class in addition to its own details.
The general form of defining a derived class is :
The colon indicates that the derived_class_name is derived
from the base_class_name.
The visibility mode (access specifier) is optional, if present,
may be private, public, or protected.
Class derived_class_name : visibility_mode base_class_name
{
………..// members of derived class
};
Visibility Mode
The visibility mode specifies how the features of the base
class are visible to the derived class.
Private : When a derived class privately inherits a base
class, the protected and public members of base class
become private members of the derived class.
Public : In Public mode, the protected and public members of
base class become protected and public members of derived
class respectively.
Protected : In Protected mode, the protected and public
members of base class become protected members of the
derived class.
Types of Inheritance
1. Single Inheritance
2. Multilevel Inheritance
3. Multiple Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance
Single Inheritance
In Single Inheritance, one derived class inherits from one
base class
Class A
Class B
Single Inheritance
class A
{
…….. // Members of base class
};
class B : public A
{
…….. // Members of derived class
};
Single Inheritance is declared as follows :
Multilevel Inheritance
In Multiple Inheritance, a class (Inter-mediate base class)
is derived from base class, which is again derived into
some other class
The class A serves as a
base class for the derived
class B, which in turn
serves as a base class
for the derived class C.
Class A
Class B
Class C
Multilevel Inheritance
class A
{
……… //Members of base class
{;
class B : public A
{
……… //Members of derived class, B derived from A
};
class C : public B
………. //Members of derived class, C derived from B
};
Multilevel Inheritance is declared as follows :
Multiple Inheritance
In Multiple Inheritance, a class is derived from more than
one base classes
Class C
Class BClass A
Base
Classes
Derived Class
Multiple Inheritance
class A
{
……… //Members of base class A
{;
class B
{
……… //Members of base class B
};
class C : public A, public B
{
………. //Members of derived class
};
Multiple Inheritance is defined as follows :
Hierarchical Inheritance
In Hierarchical Inheritance, one base class is inherited into
two or more Derived Classes
Class A
Class B Class C
Base Class
Derived Class
Hierarchical Inheritance
class A
{
……… //Members of base class A
{;
class B : public A
{
……… //Members of Derived class , B derived from A
};
class C : public A
{
………. //Members of derived class , C derived from A
};
Hierarchical Inheritance is declared as follows
Hybrid Inheritance
In Hybrid Inheritance, more than one type of inheritances
are used to derive a new Sub Class.
For example, inheriting a class from two different classes,
which in turn have been derived from the same base class.
Any legal combination of other four types of inheritance
comes under Hybrid Inheritance
Hybrid Inheritance
Class A
Class B Class C
Base Class
Class D Derived Class
Intermediate
Base Class
Hybrid Inheritance
class A
{
………..
………..
};
class B : public A
{
……….
};
class C : public A
{
………..
};
class D : public B, public C
{
………
};
A basic form of Hybrid Inheritance :
Virtual Base Class
Virtual base class is a way of preventing multiple
instances(duplicate copies) of a given class appearing in
an inheritance hierarchy when using multiple/hybrid
inheritance.
Suppose we have a base class called ‘A’ and two classes
derived from it ‘B’ and ‘C’ and we derived class ‘D’ from
class ‘B’ and ‘C’.
That means all the members of class ‘A’ are inherited into
‘D’ twice, first via ‘B’ and again via ‘C’ This means, class
‘D’ would have duplicate sets of members inherited from
‘A’. This is an ambiguous situation
Virtual Base Class
class A
{
………..
………..
};
class B : virtual public A
{
……….
};
class C : virtual public A
{
………..
};
class D : public B, public C
{
………
};
This is how we create Virtual Base Class
Abstract Class
An abstract class is one that is not used to create
objects.
An abstract class is designed only to act as a base class
to be inherited by other classes.
It is a design concept in program development and
provides a base upon which other classes may be built
Advantages of Inheritance
Reusability : Inheritance helps the code to be reused in
many situations. The base class is defines and once it is
compiled, it need not be reworked. Using the concept of
Inheritance, the programmer can create as many derived
classes from the base class as needed while adding
specific features to each derived class as needed
Saves Time and Effort : The above concept of reusability
achieved by inheritance saves the programmer’s time
and effort. Since the main code written can be reused in
various situations as needed

Mais conteúdo relacionado

Mais procurados (20)

Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Interface
InterfaceInterface
Interface
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
 
Method overriding
Method overridingMethod overriding
Method overriding
 

Semelhante a Inheritance in OOPS

Semelhante a Inheritance in OOPS (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
inheritence
inheritenceinheritence
inheritence
 
iheritence.pptx
iheritence.pptxiheritence.pptx
iheritence.pptx
 
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
Ritik (inheritance.cpp)
Ritik (inheritance.cpp)Ritik (inheritance.cpp)
Ritik (inheritance.cpp)
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
 
Inheritance
InheritanceInheritance
Inheritance
 
MODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computerMODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computer
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance (with classifications)
Inheritance (with classifications)Inheritance (with classifications)
Inheritance (with classifications)
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
week14 (1).ppt
week14 (1).pptweek14 (1).ppt
week14 (1).ppt
 

Último

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

Último (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

Inheritance in OOPS

  • 2. What is Inheritance ? Inheritance is a relationship between two or more classes where derived class inherits properties of pre- existing (base) classes. Base Class: It is the class whose properties are inherited by another class. It is also called Super Class or Parent Class. Derived Class: It is the class that inherit properties from base class(es). It is also called Sub Class or Child Class.
  • 3. Concept of Inheritance Base Class Property A Property B Property C Property D Property C Property B Property A Derived Class Defined in Derived Class Defined in Base Class But accessible from Derived Class
  • 4. Defining Derived Classes A derived class can be defined by specifying its relationship with the base class in addition to its own details. The general form of defining a derived class is : The colon indicates that the derived_class_name is derived from the base_class_name. The visibility mode (access specifier) is optional, if present, may be private, public, or protected. Class derived_class_name : visibility_mode base_class_name { ………..// members of derived class };
  • 5. Visibility Mode The visibility mode specifies how the features of the base class are visible to the derived class. Private : When a derived class privately inherits a base class, the protected and public members of base class become private members of the derived class. Public : In Public mode, the protected and public members of base class become protected and public members of derived class respectively. Protected : In Protected mode, the protected and public members of base class become protected members of the derived class.
  • 6. Types of Inheritance 1. Single Inheritance 2. Multilevel Inheritance 3. Multiple Inheritance 4. Hierarchical Inheritance 5. Hybrid Inheritance
  • 7. Single Inheritance In Single Inheritance, one derived class inherits from one base class Class A Class B
  • 8. Single Inheritance class A { …….. // Members of base class }; class B : public A { …….. // Members of derived class }; Single Inheritance is declared as follows :
  • 9. Multilevel Inheritance In Multiple Inheritance, a class (Inter-mediate base class) is derived from base class, which is again derived into some other class The class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C. Class A Class B Class C
  • 10. Multilevel Inheritance class A { ……… //Members of base class {; class B : public A { ……… //Members of derived class, B derived from A }; class C : public B ………. //Members of derived class, C derived from B }; Multilevel Inheritance is declared as follows :
  • 11. Multiple Inheritance In Multiple Inheritance, a class is derived from more than one base classes Class C Class BClass A Base Classes Derived Class
  • 12. Multiple Inheritance class A { ……… //Members of base class A {; class B { ……… //Members of base class B }; class C : public A, public B { ………. //Members of derived class }; Multiple Inheritance is defined as follows :
  • 13. Hierarchical Inheritance In Hierarchical Inheritance, one base class is inherited into two or more Derived Classes Class A Class B Class C Base Class Derived Class
  • 14. Hierarchical Inheritance class A { ……… //Members of base class A {; class B : public A { ……… //Members of Derived class , B derived from A }; class C : public A { ………. //Members of derived class , C derived from A }; Hierarchical Inheritance is declared as follows
  • 15. Hybrid Inheritance In Hybrid Inheritance, more than one type of inheritances are used to derive a new Sub Class. For example, inheriting a class from two different classes, which in turn have been derived from the same base class. Any legal combination of other four types of inheritance comes under Hybrid Inheritance
  • 16. Hybrid Inheritance Class A Class B Class C Base Class Class D Derived Class Intermediate Base Class
  • 17. Hybrid Inheritance class A { ……….. ……….. }; class B : public A { ………. }; class C : public A { ……….. }; class D : public B, public C { ……… }; A basic form of Hybrid Inheritance :
  • 18. Virtual Base Class Virtual base class is a way of preventing multiple instances(duplicate copies) of a given class appearing in an inheritance hierarchy when using multiple/hybrid inheritance. Suppose we have a base class called ‘A’ and two classes derived from it ‘B’ and ‘C’ and we derived class ‘D’ from class ‘B’ and ‘C’. That means all the members of class ‘A’ are inherited into ‘D’ twice, first via ‘B’ and again via ‘C’ This means, class ‘D’ would have duplicate sets of members inherited from ‘A’. This is an ambiguous situation
  • 19. Virtual Base Class class A { ……….. ……….. }; class B : virtual public A { ………. }; class C : virtual public A { ……….. }; class D : public B, public C { ……… }; This is how we create Virtual Base Class
  • 20. Abstract Class An abstract class is one that is not used to create objects. An abstract class is designed only to act as a base class to be inherited by other classes. It is a design concept in program development and provides a base upon which other classes may be built
  • 21. Advantages of Inheritance Reusability : Inheritance helps the code to be reused in many situations. The base class is defines and once it is compiled, it need not be reworked. Using the concept of Inheritance, the programmer can create as many derived classes from the base class as needed while adding specific features to each derived class as needed Saves Time and Effort : The above concept of reusability achieved by inheritance saves the programmer’s time and effort. Since the main code written can be reused in various situations as needed

Notas do Editor

  1. This is just opposite of Multiple Inheritance
  2. This is a combine form of Multiple and Hierarchical Inheritance.