|
For question 1:
A container class can be implemented as a local class. But a local class is not persé a container and vice versa.
Local classes are usually use to protect an entire class or struct within the private section of the containing class. This may cause some problems when forward declaration is needed.
For question 2:
Coding wise they can be the same. Relation/design wise too.
However, design wise composition is usually meant to define datastructures.
Aggregation may holds the same relationship design wise, but its intent is for combining classes to define its requirements.
During composition (containers), if the holding class cease to exist, the contained of class-instance cease to exist as well.
__________________
|