24 Oct 2023
Beginner
Inheritance enables one class to inherit properties and characteristics from another class. The class whose properties and characteristics are inherited is known as the base class or parent class. The class that inherits the properties from the base class is known as the derived class or child class.
Examples:
- Basic Example:
- Class
Vehiclehas properties likecolorandspeed. - Class
Carinherits fromVehicleand adds its properties likebrand.
- Class
- Real-world Analogy:
- Think of inheritance like a family tree; children inherit traits and characteristics from their parents.
object-oriented-programming
inheritance