【发布时间】:2010-12-01 23:12:26
【问题描述】:
我有密码
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:在函数“int SDL_main(int, char**)”中:
\main.cpp:169: 错误:'switchstate' 不能用作函数
我以前从未使用过枚举,所以我对什么不起作用感到困惑。
【问题讨论】:
标签: c++ enums compiler-errors enumeration