Inheritance

Inheritance is obtaining the capabilities on an object.

Python Example

For more Python class related examples, see:

# Define a super class that inherits the object base class.
class Vehicle(object):
    def __init__(self, name): 
        self.name = name
    def getName(self): 
        return self.name
    def isCar(self): 
        return False
  

# Define a sub class that inherits the super class Vehicle specified as a parameter.
class Car(Vehicle):
    def isCar(self):
        return True
        

# Use the super class and sub class.
vehicle = Vehicle("Ford")
print(vehicle.getName(), vehicle.isCar())
car = Car("Toyota")
print(car.getName(), car.isCar())