开发者

objective c++ class not working

开发者 https://www.devze.com 2023-03-07 11:45 出处:网络
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:

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

精彩评论

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