A class can have references to objects of other classes as members. This 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’s supposed to sound its alarm, so it’s reasonable to include two references to
Time objects in an
Software Engineering Observation 10.5
One form of software reuse is composition, in which a class contains references to other objects. A class can have a property of its own type—for example, a Person class could have a Mom property of type Person.
Our example ...