June 2006
Intermediate to advanced
1344 pages
42h 52m
English
A class can have references to objects of other classes as members. Such a capability is called composition and is sometimes referred to as a has-a relationship. For example, an object of class AlarmClock needs to know the current time and the time when it is supposed to sound its alarm, so it is reasonable to include two references to Time objects as members of the AlarmClock object.
Software Engineering Observation 9.5
|
| One form of software reuse is composition, in which a class has as members references to objects of other classes. |
Our example of composition contains two classes—Day (Fig. 9.5) and Employee (Fig. 9.6)—and module ...
Read now
Unlock full access