I was just trying to do a simple test using a static member, but my code won't compile and I don't know what's wrong. I tried accessing the variable through and instance of the class as well, but that also didn't work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <conio.h>
usingnamespace std;
class A {
public:
staticint i;
};
int main() {
A::i = 123;
cout << A::i << endl;
_getch();
return 0;
}