This
class X
{
int x = 2;
string y {"smt"};
int tab[3] = {1,2,3}; // or tab[3] {1,2,3}
};
is possible in a new C++ 11 standard, as far as i know. However none of this is allowed in Visual Studio 2012 V3 or 2013. The first one gives:
error C2864: 'A::a' : only static const integral data members can be initialized within a class
the second and third errors about the ';' and '{' .
Does it basically mean that those features are still unavailable in the MS compiler? What compiler actually supports that? I searched for the answers about in-class initialization in Visual but found nothing specific about the latest versions.
Thanks in advance.
No, non-static data member initializers not supported by Microsoft compiler. Herb Sutter announced that it will be implemented in Visual Studio 2013 RTM. (Link)
Mr. Sutter said that main reason for such a delay in implementing C++11 features is that Microsoft trying to implement C++14 features same time, because they are tightly coupled. So, probably, we will gain some C++14 features in VS2013 release too.
Other major compilers:
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