enums - Enumerations in C++ -


i have code

void switchstate(gamestates state) --line 53 { --line 54     switch(state)     case state_title:         title();         break;     case state_about:         break;     case state_game:         break;     case state_battle:         break; }  enum gamestates { state_title, state_about, state_game, state_battle, };   int main( int argc, char* args[] ) { gamestates currentstate = state_title; startup(); load_resources(); switchstate(currentstate); --line 169 return 0; } 

and when try compile errors:

\main.cpp:53: error: 'gamestates' not declared in scope
\main.cpp:54: error: expected ',' or ';' before '{' token
\main.cpp: in function 'int sdl_main(int, char**)':
\main.cpp:169: error: 'switchstate' cannot used function

i've never used enumerations before i'm confused on what's not working.

generally, errors of "<symbol> not in scope" means compiler hasn't seen <symbol> yet. move declaration of gamestates before void switchstate(...), either via earlier #include or moving in file.

c , c++ compile top bottom, symbols must declared before used.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -