2
Reply

What is aggregation? How can we get an interface of the aggregated object?

Tushar Agrawal

Tushar Agrawal

18y
8.2k
0
Reply

    Aggregation is a whole-part relationship. For example, a magnetron will still be magnetron if you remove it from microwave but microwave will just be a box without magnetron.

    1. Aggregation is the reuse mechanism, in which the outer object exposes interfaces from the inner object as if they were implemented on the outer object itself. This is useful when the outer object would always delegate every call to one of its interfaces to the same interface in the inner object. Aggregation is actually a specialized case of containment/delegation, and is available as a convenience to avoid extra implementation overhead in the outer object in these cases. We can get a pointer to the inner interface, calling QueryInterface of the outer object with IID of the inner interface.