class里定义enum的用法

来源:互联网 发布:mac chili铁锈红 编辑:程序博客网 时间:2024/05/28 04:53

enum可以这样用:

Status x = INVALID
然后你再把类加上去看看
枚举类型里面的值就是常量

class EventType {
    public:
        enum Type {
            INVALID,

   //Report ethernet network status
   REPORT_ETHERR = 0x11,
   
   ENABLE_ENCODER = 0xD0,
   DEVICESTATUS_POLL = 0xB0,
   CTRL_AUDIO_VOICE = 0xE1,
   LCDSTATUS_POLL = 0xE3,
   LCD_SAVE_ENERGY = 0xE4,
        };
        static EventType::Type convert(unsigned int eventType);
        static string name(EventType::Type type);
};

class Event {
    public:
        Event(EventType::Type type=EventType::INVALID,
              EventStatus::Status status=EventStatus::ORIGINAL);//  ORIGINAL = 0x30,

原创粉丝点击