Next: 2.3.2.2 Code reuse and
Up: 2.3.2 Illustrative Examples
Previous: 2.3.2 Illustrative Examples
One application of multiple inheritance is to provide an implementation
of an abstraction, using a concrete class. This has been called ``the
marriage of convenience'' in [27]. In C++, private inheritance
is used for a similar purpose.
In both cases the inheriting class is not intended to be a subtype of
the concrete class, it just reuses its code to implement the interface
of the abstraction. In Java, this corresponds to a child class that
forwards to the concrete class and inherits from an abstract class (or
implements an interface) that represents the abstraction. An example
would be an abstract class Stack3
that can be implemented using different underlying concrete data types,
for example, an Array or a LinkedList.
T. K. Prasad