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 ...

Get Core C++ A Software Engineering Approach 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.