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, ...
Get Sams Teach Yourself C++ in 21 Days , Fifth Edition 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.