Aggregation

In this lesson, you'll get familiar with a new way of linking different classes.

We'll cover the following

Aggregation follows the has-A model. This creates a parent-child relationship between two classes, with one class owning the object of another.

So, what makes aggregation unique?

Independent Lifetimes

In aggregation, the lifetime of the owned object does not depend on the lifetime of the owner.

The owner object could get deleted, but the owned object can continue to exist in the program. In aggregation, the parent only contains a reference to the child, which removes the child’s dependency.

Get hands-on with 1400+ tech skills courses.