There is one difference: A1and A3 the aggregate type , and A2not, as it has a user -defined constructor.
the type of class (usually struct or union) that has
- ...
, inherited, or explicit (since C++17) (explicitly defaulted or deleted constructors are allowed) (since C++11)- ...
, A1 A3 , A2 .
A1 a1{99}; // fine; n is initialized to 99
A3 a3{99}; // fine; n is initialized to 99
A2 a2{99}; // error; no matching constructor taking int found
a1.n, a2.n, a3.n ++?
, , , . , - zero initialized.