Inheritance

I l @ ve RuBoard

Inheritance defines a relationship among classes where one class shares the structure and/or behavior of one or more classes. A hierarchy of abstractions is created in which a subclass inherits from one or more superclasses. Inheritance is also called an "is-a" or " kind-of " hierarchy. A subclass will inherit all attributes, operations, and relationships defined in any of its superclasses. Thus, attributes and operations are defined at the highest level in the hierarchy at which they are applicable , which allows all lower classes in the hierarchy to inherit them. Subclasses may be augmented with additional attributes and operations that apply only to that level of the hierarchy. A subclass may supply its own implementation of an operation. Since an inheritance relationship is not a relationship between different objects, the relationship is never named, role names are not used, and multiplicity does not apply.

There is no limit to the number of classes allowed in an inheritance hierarchy. However, practical experience has shown that typical C++ class hierarchies contain between three and five layers , whereas Smalltalk applications may be a bit deeper.

Inheritance is the key to reuse. A class can be created for one application and then a subclass may be created to add more information needed for a different application.

There are two ways to find inheritance ”generalization and specialization. Both methods typically are used for any system under development.

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net