O'Reilly logo

Sams Teach Yourself C++ in 21 Days , Fifth Edition by Bradley Jones, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Day 16. Advanced Class Relationship

So far, you have worked with single and multiple inheritance to create is-a relationships.

Today, you will learn

• What aggregation is and how to model it (the has-a relationship)

• What delegation is and how to model it

• How to implement one class in terms of another

• How to use private inheritance

Aggregation

You have seen in previous examples that it is possible for the member data of a class to contain objects of other class types. This is often called aggregation, or the has-a relationship.

As an illustration, consider classes such as a Name class and an Address class:

Class Name{     // Class information for Name};Class Address{     // Class information for Address};

As an illustration of aggregation, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required