4.1.3. Support for composition in other languages
Composition is to some degree supported in object-oriented languages
•
Part objects. C++ and Eiffel [Mey88] support part objects. In C++ a class attribute
may be a instance of another class. In Eiffel it is a property of the class whether or not
an instance of it is a part object. This means that all instances of a class are either part
objects or referenced from other objects. They cannot be both.
In BETA a part object may be an instance of any class and a part object may also be
referenced from other objects.
In BETA a part object may also bind virtual patterns
5
in the object being instantiated
and operations in the part object may thus have an effect upon the enclosing object.
This is possible by combining a part object with block structure and singular objects.
This feature is a useful alternative to multiple inheritance, which is further discussed in
section 4.2.
•
Do'stlaringiz bilan baham: |