Possible Duplicate:
Defining static members in C++
I am working little bit on C++, and I don't understand how to use static fields in C++, they seem useless. Please correct me.
I cannot do that:
class AClass{ public: static int static_field = 0; }; AND THAT does not work either
class AClass{ public: static int static_field; }; int main(){ int AClass::static_field = 0; return 0; }
@w00teand others have already answered the question. I think your confusion arises from the fact that in C++ declaration and definition are two different things. One makes the symbol visible , the other allocates storage. Do a search on "C++ declaration vs definition" or similar.