AdaPower Logged in as Guest
Ada Tools and Resources

Ada 95 Reference Manual
Ada Source Code Treasury
Bindings and Packages
Ada FAQ


Join >
Home >
Articles >
Getting Started >
Ada FAQ >
Source Treasury >
Books & Tutorials >
Packages for Reuse >
Latest Additions >
Ada Projects >
Press Releases >
Ada Audio / Video >
Home Pages >
Links >
Contact >
About >
Login >
Back
Does Ada have multiple inheritance?

Ada supports multiple inheritance with a building block approach rather than a language construct. Most uses of multiple inheritance fall into one of three idioms  each of which can be implemented in Ada:

Combining Implementation and Abstraction:

Combining two classes, one that defines the protocol of the component, and another that provides an implementation. In Ada, one may implement one type in terms of another, and hide that implementation as a private type.

Mixin Inheritance:

One of the parent classes cannot have instances of its own and exists only to provide a set of properties for classes inheriting from it. Ada 95 can provide mixin inheritance using tagged type extension (single inheritance) and generic units. The generic template defines the mixin. The type supplied as generic actual parameter determines the parent.

Multiple Views:

The derived type or class is truly a derivative of more than one parent and clients of that type want to "view it" as any of its parents. This may be accomplished in Ada 95 using access discriminants which effectively enable us to parameterize one record with another.

An access discriminant can be used to enable a component of a record to obtain the identity of the record in which it is embedded. This enables complex chained structures to be created and can provide multiple views of a structure.

(T.E.D)


(c) 1998-2004 All Rights Reserved David Botton