c++ - 使用枚举名称

标签 c++ enums

如果有人使用 enum 名称,如下所示:

class Logger
{
 public:
           enum LEVEL
           {
               Debug,
               Warning,
               Notification,
               Error
           };
};

这件事在这里意味着什么:

Logger(LEVEL);

最佳答案

这看起来像一个构造函数的声明,使用方式如下:

struct Logger
{
    enum LEVEL { Debug, Warning, Notification, Error };
    Logger(LEVEL);
    // ...
};

Logger wlogger(Logger::Warning);
Logger elogger(Logger::Error);

关于c++ - 使用枚举名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9859532/

相关文章:

c++ - vector 声明和大小分配

java - 在 switch case 中使用枚举,但不作为 switch 参数

swift - 枚举关联值和泛型

c++ - 如何在 Mac 上用 C++ 显示模态消息框?

java - 获取枚举类型的所有实例的列表并在 View 中迭代

c# - 值得将枚举转换为它的值的场景

.net - C# - 都是枚举常量吗?

c++ - for_each 算法导致 basic_string::_M_construct null 在 C++ 中无效

c++ - Qt : "clear" composition mode clears everything underneath it 中的 cairo_push_group 模拟

c++ - 在 WinAPI 中为控制台应用程序处理窗口关闭事件的最简单方法是什么?