Shouldn't members that are initialized in-class be composite members? Why does it matter to anyone that C++11 dictated that members that are initialized in-class cannot be aggregate members? I cannot think of a situation in which it would even be possible to initialize a proper aggregation member in-class. For context, the final paragraph of this answer is what sparked this question, and below are notes that outline my understanding of compositions vs. aggregations.
-> Composition vs. Aggregation and In-class vs. Initializer list
member initialization
Composition and aggregation members:
- Are part of the object.
- Do NOT know about the existence of the object.
Composition members:
- Can only belong to one object.
- Existence is managed by the object to which it belongs.
Aggregation members:
- Can belong to multiple objects.
- Existence is NOT managed by the object to which it belongs.
In-class and initializer list member initialization:
- Can initialize const members.
In-Class member initialization:
- Done in the header file where the class is defined.
Initializer list member initialization:
- Done before the body of a constructor for the class.
As this topic pertains to C++:
- Prefer composition (more consistent clean-up).
- Composition members are cleaned up by the object to which they belong.
- Aggregation members are NOT cleaned up by the object to which they belong.
- C++11 dictates that in-class member initializers preclude the member from
being part of an aggregation.