Member intializer list error...

1
2
3
4
5
6
7
8
9
10
11
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?
Last edited on
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.
Last edited on
Too old to compile

1
2
Something(string n)
		:a{ n } {};


but not too old to compile

1
2
	Something()
		:b{ 10 };


?

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.
Last edited on
Awesome! Tyvm! I just discovered VS 2015 existed, I'm updating now. Thanks for your help!
Topic archived. No new replies allowed.