开发者

objective c++ class not working

I have this in my .hpp file:

class MD
{
public:
    static const开发者_运维知识库 int Blk = 0;
}

And this in a method in .mm file that includes the .hpp file:

int i = MD.Blk;

the compiler says error: expected primary-expression before '.' token on this line.

If I comment it the line out everything works fine.

What am I doing wrong?


Try the :: operator

int i = MD::Blk;


The correct way to refer static class member variables is using the :: operator, like this:

int i = MD::Blk;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜