Where is the correct place to initialize a class data member? I have the class declaration in a header file like this:
Foo.h:
class Foo {
private:
int myInt;
};
Then I try to set a value to myInt in the corresponding .cpp file:
Foo.cpp:
int Foo::myInt = 1;
I get a compiler error for redefining myInt. What am I doing wrong???