vendredi 3 juin 2016

Initializing static data member from non-static member

I'm trying to initialize a static member variable from a sizeof of a non-static:

class Myclass
{
   int a;
   static const int b = sizeof(a);
};

This should be legal with c++11, right? It gives me compiler error C2327 ("a is no typename not static and no enumerator).

Compiler is Visual Studio 2015 Express.

Aucun commentaire:

Enregistrer un commentaire