开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜