| Home | Previous Lesson: Inheritance Next Lesson: Inheriting the Code |
In this example, Vehicle class is called a base class. Base classes are not meant to be used directly, but they are used to define the general attributes that appear in the derived objects. As you descend the hierarchy, you define more specific attributes and functionality.
The descendant class, a Taxi, inherits all attributes, variables, structures, functions and behavior from the ancestor, the Car class. An ancestor can have any number of descendant classes, and a descendant class can become an ancestor to other descendants. The attributes defined at the ancestor level are not copied into the descendant class, but are passed down to the descendant for reference.
If you change attributes at the ancestor level, the changes reflect in descendent objects immediately. At the same time, changes done at the descendent level are not reflected at the ancestor level. In the above example, additional functionality defined at Car class is available to Taxi, but not to the Vehicle class. This allows you to localize changes and localize testing.
| Home | Previous Lesson: Inheritance Next Lesson: Inheriting the Code |