Reputation: 59
I don't understand why we can assign values directly to mi
. Usually, we use a format like mi.a
but this turns out syntax error in this case. Could someone explain to me?
struct myInt {
int a[7];
};
myInt mi;
mi= { 1,2,3,4,5,6,7 };
Upvotes: 0
Views: 82
Reputation: 15164
It is an initializer, C++ allows recursive initialization of aggregates, that is you don't need a second set of { } in the initializer if it can't be ambigious (as it can not here as there are no other memebrs to initialize).
Upvotes: 2