Inheritance is the process of creating a new class from existing classes. The newly created class inherits the properties from the existing class. During the whole process, the already existing class remains unchanged.
The already existing class is known as base class/master class/parent class/superclass and the newly created class is known as derived class/client class/child class / subclass.
Need for inheritance
Inheritance is a splendid concept of an object-oriented language. There are several reasons why inheritance was introduced into an object-oriented language.
1. One major reason behind this is the capability to express the inheritance relationship which ensures the closeness with the real-world models.
2. Another reason is the idea of reusability. The advantages of reusability are :
* Faster development time,
* Easier maintenance and
* Easy to extend.
Inheritance allows the addition of additional features to an existing class without modifying it.
One can derive a new class from an existing class and add new features to it.
Advantages of inheritance
* Reusability of code
* Reliability of code
* Helps us to extend an existing class i.e. it helps us to add new properties to an existing class without modifying it.