I have enum declared in a header file called “sm.h”
enum GameStates
{
STATE_NULL = 0,
STATE_INTRO,
STATE_TITLE,
STATE_MAIN,
STATE_EXIT
};
All it does is list the possible game states
However in the following line in “base.cpp”:
stateID = STATE_INTRO;
The compiler says “STATE_INTRO was not declared in this scope”. I have no idea what I am doing wrong. I know that I have included the header file right and I can go to its deceleration from the .cpp file. So why am I getting this error.
stateID = STATE_INTRO;
Is used in:
bool baseFunctions::load_rc()
{
stateID = STATE_INTRO;
currentState = new Intro();
return true;
}
which defines a class function in a header file.
There are no global conflicts because it is the only enum in the whole program
From your link to your files, you have the following in both
sm.handbase.hChange the one in
sm.hto something likeand I expect you’ll be fine.
As it is,
base.cpploadsbase.h, then when it gets tosm.hthe #ifndef is false, so it excludes everything insm.h.