Domanda

According to C++11 Features (Modern C++), VC++ 2013 now supports non-static data member initializers.

However, the following code is rejected by VC++ 2013:

struct A
{
    const int n = 0; // error C2864
};

error C2864: 'A::n' : only static const integral data members can be initialized within a class

What's the root cause? Is it a compiler bug?

È stato utile?

Soluzione

What's the root cause? Is it a compiler bug?

It's a documentation bug, both here and chris's link in the comment say that Non-static data member initializers will be implemented in VS2013 RTM.

Don't be surprised when you find false info on MSDN, there is a lot of old material, etc. which no one has updated or somebody made a mistake when typing it in.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top