Summary
In this chapter, we looked at the use of C++ classes as components of a relationship: class composition. This is the way we should think of classes—not as stand-alone segments of code but as cooperating components related to each other.
The relationship of aggregation is one of the most popular relationships among classes. Using class objects as data members of other classes poses a number of technical and conceptual issues: how to define class components and how to initialize them to the appropriate state so that they can be used by their client, the component class.
We also looked at other ways to link class objects using pointers and references. This is even a more powerful technique of setting up relationships among objects, and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access