SlideShare a Scribd company logo
Object-Oriented
Programming: Inheritance
Outline
• Introduction
• Protected members in inheritance
• Relationship between Base Classes and Derived Classes
• Benefits and Drawbacks of Inheritance
• Constructors and Destructors in Derived Classes
• Public, Protected and Private Inheritance
• Software Engineering with Inheritance
Introduction
• Inheritance is a core concept in object-oriented programming (OOP).
It allows a class to inherit properties and behaviors from another
class. This is a powerful way to reuse code and promote code
abstraction.
• Inheritance works by creating a subclass that inherits from a
superclass. The subclass inherits all of the attributes and methods of
the superclass, and it can also add its own attributes and methods.
• Parent – Child Relationship.
Types of inheritance
Here are some of the types of inheritance:
• Single inheritance: A subclass inherits from a single superclass.
• Multiple inheritance: A subclass inherits from multiple superclasses.
• Hierarchical inheritance: A class hierarchy is formed when a subclass
inherits from another subclass.
• Hybrid inheritance: A mix of two or more of the above types of
inheritance occurs.
Syntax
class Subclass’Name : access_specifier BaseClass’Name {
// members of subclass
};
The access_specifier can be one of the following:
• public: The subclass inherits all of the public members of the base
class.
• protected: The subclass inherits all of the protected members of the
base class.
• private: The subclass inherits none of the members of the base class.
Example
Animal class is Base Class/parent
class and Dog class is Derived
class/sub class.
Protected members in inheritance,oop,c++
In C++, protected members are members of a class that can only be
accessed by the class itself, its subclasses, and friends.
• Protected members are similar to private members, but they can be
inherited by subclasses. Private members are not accessible to
subclasses or friends.
• The syntax for declaring a protected member in C++ is:
class MyClass {
protected:
int x;
};
Relationship between Base Classes and
Derived Classes
In C++, a base class is a class from which other classes are derived. The
derived classes are called subclasses. The base class is the "parent" of the
subclasses, and the subclasses are the "children" of the base class.
The relationship between a base class and its subclasses is one of
inheritance. This means that the subclasses inherit all of the properties and
behaviors of the base class. The subclasses can then add their own properties and
behaviors, or they can override the properties and behaviors of the base class.
Benefits and Drawbacks of Inheritance
Here are some of the benefits of using inheritance in C++:
I. It allows us to reuse code.
II. It helps us to organize our code.
III. It can help us to make our code more robust and easier to
maintain.
Here are some of the drawbacks of using inheritance in C++:
I. It can make the code more complex.
II. It can make it difficult to track down the source of errors.
Constructors and Destructors in Derived Classes
When a subclass inherits from a base class, the subclass inherits the base class's constructors and
destructors. However, the subclass can also define its own constructors and destructors.
If the subclass defines its own constructors, the base class's constructors will be called
automatically when the subclass object is created.
The order in which the constructors are called is as follows:
• The base class's default constructor is called.
• The subclass's default constructor is called.
• If the subclass defines any parameterized constructors, they are called in the order that they are
defined.
If the subclass defines its own destructor, the base class's destructor will be called automatically
when the subclass object is destroyed. The order in which the destructors are called is as follows:
• The subclass's destructor is called.
• The base class's destructor is called.
Example
When a DerivedClass object is created,
the following happens:
• The BaseClass class's default constructor
is called.
• The DerivedClass class's default
constructor is
called.
When a DerivedClass object is destroyed,
the following happens:
• The DerivedClass class's destructor is
called.
• The BaseClass class's destructor is
called.
Public, Protected and Private Inheritance
• Public inheritance is the default type of inheritance in C++. When a class
inherits from another class in public mode, the subclass inherits all of the
public members of the base class. This means that the subclass can access
the public members of the base class as if they were its own members.
• Protected inheritance is a type of inheritance where the subclass inherits
all of the protected members of the base class. This means that the
subclass can access the protected members of the base class, but it cannot
access the public members of the base class.
• Private inheritance is a type of inheritance where the subclass inherits all
of the private members of the base class. This means that the subclass can
only access the private members of the base class through the base class's
methods.
Public, Protected and Private Inheritance…..
Type of inheritance Access to base class members
Public inheritance Public and protected members
Protected inheritance Protected members
Private inheritance Private members
Software Engineering with Inheritance
• Inheritance is a powerful tool in software engineering that can be used to
improve the design and implementation of our code. It allows us to reuse code
that has already been written, and it can also help us to abstract away the details
of how something works.
Here are some of the ways that inheritance can be used in software engineering:
• To create a hierarchy of classes: Inheritance can be used to create a hierarchy of
classes, where each class inherits from a more general class. This can help to
organize our code and make it easier to understand.
• To implement polymorphism: Inheritance can be used to implement
polymorphism, which allows us to treat different objects in the same way. This
can make our code more flexible and easier to use.
• To reuse code: Inheritance can be used to reuse code that has already been
written. This can save us time and effort, and it can also help to keep our code
consistent.
End
Ad

More Related Content

Similar to Object oriented programming new syllabus presentation (20)

full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
rayanbabur
 
Overview of Object Oriented Programming using C++
Overview of Object Oriented Programming using C++Overview of Object Oriented Programming using C++
Overview of Object Oriented Programming using C++
jayanthi699330
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
INHERITANCES.pptx
INHERITANCES.pptxINHERITANCES.pptx
INHERITANCES.pptx
VISHNU PRIYA NR
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
Arslan Waseem
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
NithyaNithyav
 
java part 1 computer science.pptx
java part 1 computer science.pptxjava part 1 computer science.pptx
java part 1 computer science.pptx
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
10.Inheritance.ppt for oops programinggg
10.Inheritance.ppt for oops programinggg10.Inheritance.ppt for oops programinggg
10.Inheritance.ppt for oops programinggg
sanketkashyap2023
 
Inheritance
Inheritance Inheritance
Inheritance
sourav verma
 
C# structure
C# structureC# structure
C# structure
ElangovanTechNotesET
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...
vaishalisharma125399
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
RatnaJava
 
Topic inheritance
Topic  inheritanceTopic  inheritance
Topic inheritance
Ankit Kumar
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Shweta Shah
 
27c
27c27c
27c
Sireesh K
 
27csharp
27csharp27csharp
27csharp
Sireesh K
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
Muhammad Younis
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
rayanbabur
 
Overview of Object Oriented Programming using C++
Overview of Object Oriented Programming using C++Overview of Object Oriented Programming using C++
Overview of Object Oriented Programming using C++
jayanthi699330
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
Arslan Waseem
 
10.Inheritance.ppt for oops programinggg
10.Inheritance.ppt for oops programinggg10.Inheritance.ppt for oops programinggg
10.Inheritance.ppt for oops programinggg
sanketkashyap2023
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...
vaishalisharma125399
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
RatnaJava
 
Topic inheritance
Topic  inheritanceTopic  inheritance
Topic inheritance
Ankit Kumar
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Shweta Shah
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
Muhammad Younis
 

Recently uploaded (20)

How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Gojek Clone App for Multi-Service Business
Gojek Clone App for Multi-Service BusinessGojek Clone App for Multi-Service Business
Gojek Clone App for Multi-Service Business
XongoLab Technologies LLP
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Ad

Object oriented programming new syllabus presentation

  • 2. Outline • Introduction • Protected members in inheritance • Relationship between Base Classes and Derived Classes • Benefits and Drawbacks of Inheritance • Constructors and Destructors in Derived Classes • Public, Protected and Private Inheritance • Software Engineering with Inheritance
  • 3. Introduction • Inheritance is a core concept in object-oriented programming (OOP). It allows a class to inherit properties and behaviors from another class. This is a powerful way to reuse code and promote code abstraction. • Inheritance works by creating a subclass that inherits from a superclass. The subclass inherits all of the attributes and methods of the superclass, and it can also add its own attributes and methods. • Parent – Child Relationship.
  • 4. Types of inheritance Here are some of the types of inheritance: • Single inheritance: A subclass inherits from a single superclass. • Multiple inheritance: A subclass inherits from multiple superclasses. • Hierarchical inheritance: A class hierarchy is formed when a subclass inherits from another subclass. • Hybrid inheritance: A mix of two or more of the above types of inheritance occurs.
  • 5. Syntax class Subclass’Name : access_specifier BaseClass’Name { // members of subclass }; The access_specifier can be one of the following: • public: The subclass inherits all of the public members of the base class. • protected: The subclass inherits all of the protected members of the base class. • private: The subclass inherits none of the members of the base class.
  • 6. Example Animal class is Base Class/parent class and Dog class is Derived class/sub class.
  • 7. Protected members in inheritance,oop,c++ In C++, protected members are members of a class that can only be accessed by the class itself, its subclasses, and friends. • Protected members are similar to private members, but they can be inherited by subclasses. Private members are not accessible to subclasses or friends. • The syntax for declaring a protected member in C++ is: class MyClass { protected: int x; };
  • 8. Relationship between Base Classes and Derived Classes In C++, a base class is a class from which other classes are derived. The derived classes are called subclasses. The base class is the "parent" of the subclasses, and the subclasses are the "children" of the base class. The relationship between a base class and its subclasses is one of inheritance. This means that the subclasses inherit all of the properties and behaviors of the base class. The subclasses can then add their own properties and behaviors, or they can override the properties and behaviors of the base class.
  • 9. Benefits and Drawbacks of Inheritance Here are some of the benefits of using inheritance in C++: I. It allows us to reuse code. II. It helps us to organize our code. III. It can help us to make our code more robust and easier to maintain. Here are some of the drawbacks of using inheritance in C++: I. It can make the code more complex. II. It can make it difficult to track down the source of errors.
  • 10. Constructors and Destructors in Derived Classes When a subclass inherits from a base class, the subclass inherits the base class's constructors and destructors. However, the subclass can also define its own constructors and destructors. If the subclass defines its own constructors, the base class's constructors will be called automatically when the subclass object is created. The order in which the constructors are called is as follows: • The base class's default constructor is called. • The subclass's default constructor is called. • If the subclass defines any parameterized constructors, they are called in the order that they are defined. If the subclass defines its own destructor, the base class's destructor will be called automatically when the subclass object is destroyed. The order in which the destructors are called is as follows: • The subclass's destructor is called. • The base class's destructor is called.
  • 11. Example When a DerivedClass object is created, the following happens: • The BaseClass class's default constructor is called. • The DerivedClass class's default constructor is called. When a DerivedClass object is destroyed, the following happens: • The DerivedClass class's destructor is called. • The BaseClass class's destructor is called.
  • 12. Public, Protected and Private Inheritance • Public inheritance is the default type of inheritance in C++. When a class inherits from another class in public mode, the subclass inherits all of the public members of the base class. This means that the subclass can access the public members of the base class as if they were its own members. • Protected inheritance is a type of inheritance where the subclass inherits all of the protected members of the base class. This means that the subclass can access the protected members of the base class, but it cannot access the public members of the base class. • Private inheritance is a type of inheritance where the subclass inherits all of the private members of the base class. This means that the subclass can only access the private members of the base class through the base class's methods.
  • 13. Public, Protected and Private Inheritance….. Type of inheritance Access to base class members Public inheritance Public and protected members Protected inheritance Protected members Private inheritance Private members
  • 14. Software Engineering with Inheritance • Inheritance is a powerful tool in software engineering that can be used to improve the design and implementation of our code. It allows us to reuse code that has already been written, and it can also help us to abstract away the details of how something works. Here are some of the ways that inheritance can be used in software engineering: • To create a hierarchy of classes: Inheritance can be used to create a hierarchy of classes, where each class inherits from a more general class. This can help to organize our code and make it easier to understand. • To implement polymorphism: Inheritance can be used to implement polymorphism, which allows us to treat different objects in the same way. This can make our code more flexible and easier to use. • To reuse code: Inheritance can be used to reuse code that has already been written. This can save us time and effort, and it can also help to keep our code consistent.
  • 15. End
  翻译: