使用结构中定义的枚举作为C++中的大小写常量
Use enum defined in a struct as case constant in C++
我有一个enum
作为头文件中定义的structure
的成员。例如,
struct abc{
enum xyz{
FIRST =1;
SEC =2;
}qw;
};
在我的.cpp
文件中,我已经包含了这个标头。我的文件中有一个switch case
,这些enums
将用作case constants
。
struct abc az;
switch(az.qw){
case FIRST:....
case SEC:...
default:..
}
但我得到错误为FIRST is not declared in this scope
。如何克服这个问题。
xyz
是在abc
的范围内定义的,因此您需要
case abc::FIRST:
等等。
相关文章:
- 切换大小写后如何阻止变量重置?
- 无法找到简单的开关大小写枚举错误
- 仿射密码解密,输出大小写不同
- 编写宏函数来更改字符串的大小写?
- 使字母检查不区分大小写
- 如何执行不区分大小写的字符串比较?
- 函数中的切换大小写语句不会切换C++
- CMake 添加不区分大小写的源文件
- 如何在不同的开关大小写语句上使用对象的类成员函数?
- 如何以 if else 或切换大小写格式对自动和编码?
- 有没有一种方法可以忽略Qt c++中的文件名大小写敏感性?
- 标题与标准标题具有相同名称但大小写不同的问题
- Rand()大小写开关在多次迭代后运行到无穷大
- 在这种情况下,如何在基类中设计开关大小写函数
- 提升program_option配置文件的不区分大小写的解析
- 复数大小写中的C++运算符 ->
- 如何提升Perl正则表达式匹配,支持区分大小写/不区分大小写
- 无法在开关大小写中调用函数 - C++
- 对字符串向量进行排序,但不区分大小写
- 开关大小写始终为默认值