game.h:
1 2 3 4 5 6 7 8
|
class Game
{
public:
enum difficulty { A,B,C }
static difficulty getGameDiff();
private:
static difficulty diff;
}
|
game.cpp:
1 2 3 4 5 6 7
|
#include "game.h"
difficulty Game::getGameDiff()
{
return gameDiff;
}
difficulty Game::gameDiff = NONEDIFF;
|
on both definition of my static member, the compiler says
'difficulty' does not name a type
Last edited on
@Thomas1965 thanks.
actually my data member diff is a private data.
i get a compile error it says:
'Game::difficulty Game::gameDiff' is private
is the only way to define it is by making it public? if i do that it will defeat the purpose of setter/getter functions.
can you explain it to me? i dont know how it differs from my code.
except from the place of definition
Last edited on
So what part that you are not fully understood about public - private class members?
i dont know why it allows the diff to be defined that way just by putting the enum outside the class.