class Something
{
public:
Something(string n)
:a{ n }, b{ 10 }, c{ 10 } {};
private:
string a;
int b;
int c;
};
gives the error: error C2797: 'Something::a': list initialization inside member initializer list or non-static data member initializer is not implemented
However,
1 2 3 4 5 6 7 8 9 10 11
class Something
{
public:
Something(string n)
:b{ 10 }, c{ 10 } { a = n; };
private:
string a;
int b;
int c;
};
Compiles without any error. Can someone please tell me why?
Your compiler is too old. The error message say this way of initializing data members has not been implemented yet. The code compiles fine for me with GCC 4.9.2.
I'm using VS Community 2013, and I'm fairly certain I've intitialized strings in a class using a member initializer list. I don't see how my compiler can be too old quite frankly.