Daniel
Daniel

Reputation: 31609

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?

Upvotes: 0

Views: 148

Answers (2)

sergio
sergio

Reputation: 69047

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

int i = MD::Blk;

Upvotes: 2

Bala R
Bala R

Reputation: 109027

Try the :: operator

int i = MD::Blk;

Upvotes: 2

Related Questions