0

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 };
0

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.