5.8. Friend Classes

Many objects require more than one class to implement their inside and outside views. In this situation, multiple classes must somehow work together to provide access to what one class needs from another. What is the proper way to design these classes? To investigate, let's create a List class (a linked list data structure) that stores character strings. This initial design of List is the basis for improved versions that appear in subsequent chapters. A second class (Node) provides some of the implementation for the List class. Figure 5.2 shows the arrangement.

Figure 5.2. List and Node classes

Node objects contain pointers ...

Get Navigating C++ and Object-Oriented Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.