samedi 14 mars 2015

Do the static (class) variables necessarily have to be const? [duplicate]



I tried compiling this in visual studio:



class A {
int a;
static int b = 0;
public:
A(int x) { a = x; }
void changeA(int x) { a = x; }
int getA() { return a; }
};


And it gives me the following error:



error C2864: 'A::b' : a static data member with an in-class initializer must have non-volatile const integral type



What seems to be the problem officer?




Aucun commentaire:

Enregistrer un commentaire