One of the compelling features of an OOP language is code reuse. Once a class has been created and tested, it should represent a block of code/functionality ready to be used.
The simplest way to make use of an already defined class is to just create an instance of it, but you can also place an object of that class inside a new class. The new class can bundle in any number of other object types to create the functionality required. This concept of building up a brand-new class by reusing existing ones is called association. This term is referred to as a Has-A relationship. Imagine you have a class called Desktop to represent a typical PC; a desktop has a hard disk, motherboard, and so on. We have already used this concept in previous code examples.
Association comes in two flavors. This detail is most of the time overlooked. The first type of composition...