jcoder
jcoder

Reputation: 30035

Initializing data members in class definition

I thought this was now valid in c++11? Have I done something wrong, or is this simply not yet implemented in visual studio 2013 at this time? I can't find anything that says it's not but I can't find anything that says it is either...

class Test
{
private:
    int* data_ = nullptr;
};

Gives me :- Error 1 error C2864: 'Test::data_' : only static const integral data members can be initialized within a class

Upvotes: 0

Views: 173

Answers (1)

Qaz
Qaz

Reputation: 61910

You're correct. MSVC12, as of the preview, does not support this feature. However, as you can see in the following image, it will when the real release comes later this year:

MSVC12 C++11 and C++14 support

Until then, you'll have to stick with a constructor initializer list.

Upvotes: 3

Related Questions