More specifically, composition is used for objects that have a has-a relationship to each other.
A car has-a metal frame, has-an engine, and has-a transmission.
A personal computer has-a CPU, a motherboard, and other components.
In a composition, the complex object “owns” all of the subobjects it is composed of.
When a composition is destroyed, all of the subobjects are destroyed as well. For example,
if you destroy a car, it’s frame, engine, and other parts should be destroyed as well.If you destroy a PC,
you would expect it’s RAM and CPU to be destroyed as well.
An aggregation is a specific type of composition where no ownership between the complex object and the subobjects is implied.
When an aggregate is destroyed, the subobjects are not destroyed.
For example, consider the math department of a school, which is made up of one or more teachers.
Because the department does not own the teachers (they merely work there), the department should be an aggregate.
When the department is destroyed, the teachers should still exist independently (they can go get jobs in other departments).
ref : http://www.learncpp.com/cpp-tutorial/103-aggregation/