Inheritance
Inheritance lets you create new classes from existing class.
Any new class that you create from an existing class is called derived class; existing class is calledbase class.
- Base Class
A base class is a class that is created with the intention of deriving other classes from it.
- Child Class
A child class is a class that was derived from another, that will now be the parent class to it.
- Parent Class
A parent class is the closest class that we derived from to create the one we are referencing as the child class.
The inheritance relationship enables a derived class to inherit features from its base class.
The derived class can add new features of its own.
Therefore, rather than create completely new classes from scratch, you can take advantage of inheritance and reduce software complexity.
Forms of Inheritance
Single Inheritance: It is the inheritance hierarchy wherein one derived class inherits from one base class.

Multiple Inheritance: It is the inheritance hierarchy wherein one derived class inherits from multiple base class(es)
Hierarchical Inheritance: It is the inheritance hierarchy wherein multiple subclasses inherit from one base class.
Multilevel Inheritance: It is the inheritance hierarchy wherein subclass acts as a base class for other classes.
Hybrid Inheritance: The inheritance hierarchy that reflects any legal combination of other four types of inheritance.
No comments:
Post a Comment