We can use members of one class inside another class by using the following ways:-
Is-A Relationship | Has-A Relationship |
---|---|
If we want to extend existing functionality with some more extra functionality then we should go for IS-A Relationship | If we don’t want to extend and just we have to use existing functionality then we should go for HAS-A Relationship |
The concept of inheriting the properties from one class to another class is known as single inheritance.
The concept of inheriting the properties from multiple classes to single class with the concept of one after another is known as multilevel inheritance.
The concept of inheriting properties from one class into multiple classes which are present at same level is known as Hierarchical Inheritance.
The concept of inheriting the properties from multiple classes into a single class at a time, is known as multiple inheritance. If the same method is inherited from both parent classes, then Python will always consider the order of Parent classes in the declaration of the child class.
Combination of Single, Multi level, multiple and Hierarchical inheritance is known as Hybrid Inheritance.