The following code is accepted by clang 3.4
struct A
{
int a[2] = {1, 2};
};
However, vc++ 2014 CTP rejects it with an error message:
error C2536: 'A::A::a': cannot specify explicit initializer for arrays
Which compiler is correct?
Yes, It is legal but VC++ does not support this feature. It is the uniform initialization of an in-class member initialization.
Of course the = sign is optional and your code is the same as the following code:
struct A
{
int a[2] {1, 2};
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With