2. What is Inheritance ?
Inheritance is one of the important
feature of the OOP. Inheritance is the
method by which objects of one class
gets the properties of another class.
3. Advantages of Inheritance?
Sometimes we need to repeat the code or
we need repeat the whole class properties.
So It helps in various ways.
1.) It saves memory space.
2.) It saves time.
3.) It will remove frustration.
4.) It increases reliability of the code
5.) It saves the developing and testing
efforts.
4. Why we use Inheritance?
To increase the reusability of the
code and to make further usable for
another classes. We use the concept
of inheritance.
5. Types of Inheritance
1.) Single Inheritance
2.) Multiple Inheritance
3.) Multilevel Inheritance
3.) Hierarchical Inheritance
4.) Hybrid inheritance
6. A derived class with only one base class.
A
B
7. A derived class with several base classes.
A
C
B
8. The mechanism of deriving a class from
another derived class.
A
C
B
11. A derived class can be defined by specifying
its relationship with the base class in addition
to its own details.
class derived-class-name : visibility-mode base-class-name
{
………//
………// members of derived class
………//
};
12. It is the keyword that controls the visibility
and availability of inherited base class
members in the derived class. It can be either
private or protected or public.
13. It is the inheritance facilitated by private
visibility mode. In private inheritance, the
protected and public members of base
class become private members of the
derived class.
Private Inheritance:
14. It is the inheritance facilitated by public
visibility mode. In public inheritance, the
protected members of base class
become protected members of the
derived class and public members of the
base class become public members of
derived class.;
Public Inheritance:
15. It is the inheritance facilitated by
protected visibility mode. In
protected inheritance , the protected
and public members of base class
become protected members of the
derived class.
Protected Inheritance: