This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The HAS-A relationship refers to creating objects as member variables. As an example, let's say you are creating a graphical user interface (GUI) for your program. Your application requires a toolbar and a menu, so we create separate classes for these:
You also need a main window for your program. Clearly, a window HAS-A menu and a window HAS-A toolbar. We can represent this relationship by creating member variables in the Window class we need to create:
As you can see, the HAS-A relationship is not complicated. It is just a way to help us realize when we should create member reference variables.