How to define a static member in case there is not header file?
How to define a static member in case there is not header file ?
The code:
class MyClass
{
};
int MyClass::staticMember;开发者_如何学JAVA // Error: class MyClass has no member staticMember!
Any help?
This will work:
//
// Inside .cpp file
//
class MyClass
{
static int staticMember;
};
int MyClass::staticMember;
If it's not in the class declaration, you can't define it.
精彩评论