Inheritance
Inheritance
Types of Inheritance
- The method of deriving a new class from an old class is called inheritance.
- The old class referred as base or super class and new class is called derived or sub class.
- Base class is also called parent class and Derived class is also called child class.
- Derived class inherits some or all the trails from the base class.
Types of Inheritance
- Single Inheritance
- Multiple Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
1.Single Inheritance:
- Here only one base class and one derived class is allowed.
- In the figure A is base class and B is derived class.
2.Multiple Inheritance:
- Here class A and class B are base class and class C is derived class.
- Class C have properties of class A and class B.
3.Multilevel Inheritance:
- Here class E is Base class.
- Class A is intermediate class and Class B is derived class.
4.Hierarchical Inheritance:
- Here Class a is base class.
- Class B, Class C and Class D are derived classes.
5.Hybrid Inheritance:
0 Comments