std::cout << _n << std::endl;
//int test::_n = 12; // Works fine!
test::_n = 15; // Doesn't work!
//a.n() = 10; // Works fine!
The line 22 is the problem. How can I initialize a static member of a class without instantiating the class first. Line 18 is not what I'm after, not is the line 24. I'd prefer to initialize test::_n in main().
So let me get that strait. staticint _n; in line 19 is not a definition, it is just a declaration, is that correct?
Does that mean that static members of a class are in fact global variables, but their scope has been limited to the class in which they have been defined?