Class Notes - Inheritance
Class Notes - Inheritance
- Definition: Mechanism of basing a class (child class) on another class (parent class).
- Types of Inheritance:
1. Single Inheritance: One child class inherits from one parent class.
4. Hierarchical Inheritance: Multiple child classes inherit from a single parent class.
- Benefits:
- Code Reusability.
- Example in Python:
```python
class Parent:
def greet(self):
class Child(Parent):
def greet_child(self):
obj = Child()
```