Reputation:
So, I have a class named "Player", within the header file I have this:
class Player
{
public:
void move(Player::Direction direction);
private:
enum Direction { LEFT, RIGHT, UP, DOWN };
};
And within the cpp file I have this:
void Player::move(Player::Direction direction)
{
}
Now my problem is, intellisense says there is no such member as direction withint the class in the header, but in the cpp file it says it's valid. When compiling I get the error: "error C2061: syntax error : identifier 'Direction'"
Upvotes: 0
Views: 2446
Reputation: 137301
The general rule in C++ is that a declaration of a thing must be seen first before said thing can be used.
Swap the declarations. (Also, the Player::
is redundant.)
class Player
{
private:
enum Direction { LEFT, RIGHT, UP, DOWN };
public:
void move(Player::Direction direction);
};
Upvotes: 1