Inheritance

In this material you have learned about:

Handling Similarities Between Classes

In object-orientation we may form hierarchies of categories (classes), by letting classes inherit the operations, methods and attributes from a "base class" or "super class".

Inheritance defines the "is-a" or "is-a-kind-of" hierarchy between classes.

Aircraft, Cars and Bicycles are all Vehicles, and share some common properties of a Vehicle, namely the attributes speed and weight and the operations move and stop. The class Vehicle is a generalization of the classes Aircraft, Car and Bicycle. Aircraft, Car and Bicycle are specializations of the class Vehicle.

In the terminology of object-oriented programming: Vehicle is the Base class or Superclass, while car is a Subclass or Derived class.

How to Use Inheritance

Inheritance may be used for:

Here is an example of inheritance in the C++ language.

Here is an example of inheritance in Modelling Diagrams.


previous | next | start | contents | dictionary | help | evaluation

© Ericsson Telecom AB, 1995, Stockholm, Sweden