6. Need for inheritance:
one basic reason behind this is the
the capability to express the
inheritance relationship.
Another reason is the idea of
reusability
one reason is transitive nature of
of inheritance
7. inheritance:
some time we need to repeat the code
or we need to repeat the whole class
properties. So it helps in various ways
it saves memory space
it saves time
it will remove frustration
it increase reliability of the code
it saves the developing and testing
efforts
8. Why we use inheritance?
To increase the reusability of the
the code and to make future usable
usable for another classes.
we use the concept of inheritance
9. How inheritance can be
achieved?
In the inheritance there will be a
a parent child relationship. There is
There is a class called in which all
all the properties are defined and
and generally, it is refered as a
base class. There is also another
another class in which is derived
derived from the existing one are
are known as a derived class.
10. Inheritance Access Specifiers
Public Inheritance
This inheritance mode is used
mostly. In this the protected
member of Base class becomes
protected members of Derived class
class and public becomes public.
11. Inheritance Access Specifiers
Protected Inheritance
In protected mode, the public and
and protected members of Base
class becomes protected members
members of Derived class.
class B : protected A
class C : protected B
12. Inheritance Access Specifiers
Private Inheritance
In private mode the public and
protected members of Base class
class become private members of
of Derived class.
class B : private A
class C : private B
13. Types of inheritance
There are different types of inheritance
inheritance
single inheritance
Multiple inheritance
Hierarchical inheritance
multilevel inheritance
hybrid inheritance
14. Single inheritance enables a
derived class to inherit properties
properties and behavior from a
single parent class. It allows a
derived class to inherit the
properties and behavior of a base
base class, thus enabling code
reusability as well as adding new
new features to the existing code.
code.
17. Derived class
In Inheritance you create new
classes from existing class. Any
new class that you create from an
an existing class is called derived
derived class.
Base class
existing class is called base class.
class.