我的代碼枚舉在C++
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;
}
,當我嘗試編譯我得到的錯誤:
\ main.cpp中:53:錯誤: 'gamestates' 沒有在這個範圍內聲明
\ main.cpp:54:錯誤:預計','或';'之前 '{' 令牌
\ main.cpp中:在函數 '詮釋SDL_main(INT,字符**)':
\ main.cpp中:169:錯誤: 'switchstate' 不能用作函數
我以前從未使用過枚舉,所以我對什麼不起作用感到困惑。