[Home]Multiple inheritance

HomePage | Recent Changes | Preferences

Difference (from prior major revision) (no other diffs)

Changed: 1,9c1,7
In Object Oriented Programming (OOP), inheritance describes the relationship between two objects. The child inherits features of the parent, allowing for shared functionality. So in the following example:

'Rat' is a child of 'Quadruped Mammal'

Features on 'Quadruped Mammal' (such as "has four legs", "begin walking", or "eat food"), are automatically a part of 'Rat' as well.

If, however, you want to follow totally orthogonal hierarchies simultaneously, such as allowing 'Rat' to inherit from 'Depicted In Cartoon' as well, without Multiple Inheritance you often end up with a very awkwardly mixed hierarchy.

Multiple Inheritance has been a touchy issue for many, with opponents pointing to its increased complexity and ambiguity (if two parents have independant implementations of a feature named X, which one do I inherit?)
In Object Oriented Programming (OOP), inheritance describes a relationship between two types, or classes, of objects in which one is said to be a "subtype" or "child" of the other. The child inherits features of the parent, allowing for shared functionality. For example, one might create a variable class "Mammal" with features such as eating, reproducing, etc.; then define a subtype "Rat" that inherits those features without having to explicitly program them, while adding new features like collecting garbage.

If, however, you want to follow more than one totally orthogonal hierarchy simultaneously, such as allowing "Rat" to inherit from "Cartoon character" and "Disease vector" as well as "Mammal", without multiple inheritance you often end up with a very awkwardly mixed hierarchy, or rewriting functionality in more than one place (with the attendant maintenance problems).

Multiple inheritance has been a touchy issue for many, with opponents pointing to its increased complexity and ambiguity (for example, if two parents have independent implementations of a feature named X, which one do I inherit?)

Languages have different ways of dealing with these problems. Eiffel, for example, allows subtypes to adapt their inherited features by renaming them or setting selection rules for them ahead of time. Java allows objects to multiply inherit interfaces but only singly inherit implementations.

In Object Oriented Programming (OOP), inheritance describes a relationship between two types, or classes, of objects in which one is said to be a "subtype" or "child" of the other. The child inherits features of the parent, allowing for shared functionality. For example, one might create a variable class "Mammal" with features such as eating, reproducing, etc.; then define a subtype "Rat" that inherits those features without having to explicitly program them, while adding new features like collecting garbage.

If, however, you want to follow more than one totally orthogonal hierarchy simultaneously, such as allowing "Rat" to inherit from "Cartoon character" and "Disease vector" as well as "Mammal", without multiple inheritance you often end up with a very awkwardly mixed hierarchy, or rewriting functionality in more than one place (with the attendant maintenance problems).

Multiple inheritance has been a touchy issue for many, with opponents pointing to its increased complexity and ambiguity (for example, if two parents have independent implementations of a feature named X, which one do I inherit?)

Languages have different ways of dealing with these problems. Eiffel, for example, allows subtypes to adapt their inherited features by renaming them or setting selection rules for them ahead of time. Java allows objects to multiply inherit interfaces but only singly inherit implementations.


HomePage | Recent Changes | Preferences
This page is read-only | View other revisions
Last edited July 27, 2001 6:12 am by Lee Daniel Crocker (diff)
Search: