c++ - QT中,报错: ISO C++ forbids forward references to 'enum' types

标签 c++ qt enums

总的错误信息是:

    /Users/me/Downloads/test/test.h:70: error: ISO C++ forbids forward references to 'enum' types
    typedef enum users_type User_Type;

我知道错误与枚举类型有关,但我仍想在我的代码中使用此类型。 你能给一些提示吗? 谢谢!

代码是:

enum uers_type{
    player,
    left_player,
    right_player,

};
typedef enum users_type User_Type;

例如,我想像这样使用这个枚举:

bool check(int){ 
if(user == (User_Type)player)
   return true;
else
   return false;
}

这些代码在不同的头上。

最佳答案

我认为这只是一个错字。应该是

...
enum users_type{
...

代替

...
enum uers_type{
...

关于c++ - QT中,报错: ISO C++ forbids forward references to 'enum' types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39887606/

相关文章:

c++ - 如何读取 C++ 中的 ini 文件?

c++ - 非常大的整数的变量类型是什么?

c++ - 覆盖 ctype<wchar_t>

c++ - QT 中有很多错误,缺少组件?

c++ - 如何在 C++ 程序中创建 KDE 托盘通知?

windows - 如何申请管理员权限?

java - 使用枚举验证 map 键集的优雅方法?

c++ - 基于指针或值类型的条件类型

c# - 在方法参数中限制枚举值

c++ - 随机生成一个没有重复元素的枚举数组(C++)