Inheritance means that a derived class inherits all attributes and methods from its super class, the class from which it is derived. This feature alleviates programmers from having to start always from scratch when writing an object-oriented applications. Many times it will be possible to design and implement a class that can be derived from existing ones in some sort of class library, which one has either written oneself or that can be obtained from another source.
In A++ in its original form inheritance is not offered as a language feature identical to the one described above, because there is no predefined syntax to define classes. It would most likely be possible to define abstractions implementing such a class system. Nobody has done it yet, because there is a very simple mechanism available that can be considered functionally equivalent to inheritance. It is called `delegation'. In our second example of object-oriented programming we will implement the inheritance using delegation.
Delegation can be very briefly explained like this: An object of a derived class receives a message from a client. If the object is equipped to provide the service it will do it. If the object does not have the proper methods to respond to the message it will delegate the message to another object, which is an instance of its super class. Messages are this way delegated up in the hierarchy until nobody can answer it, which would result in an error return.
Peter Coad compares delegation with inheritance in [CM97] and draws the conclusion that delegation should be favorized (chapter 2, page 49).
Georg P. Loczewski 2004-03-05