This question already has an answer here:
- Why do non-const, non-int/enum static data members have to be initialized outside the definition? 5 answers
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