Why I cannot initialize static field in C++

Viewed 15065

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;
}
4 Answers
Related