首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++ 多状态设立

2012-08-26 
c++ 多状态设置http://blog.csdn.net/wzq9706/article/details/7858711// 王智泉enum {ST_1 0x01 1/

c++ 多状态设置

http://blog.csdn.net/wzq9706/article/details/7858711


// 王智泉enum {ST_1 = 0x01 << 1;// 状态1ST_2 = 0x01 << 2;// 状态2ST_3 = 0x01 << 3;// 状态3ST_4 = 0x01 << 4;// 状态4ST_5 = 0x01 << 5;// 状态5};class StateTest{public:StateTest():_state(0){}~StateTest(){}// 设置指定状态// @param tag 状态// @param enable 是否打开void setState(int tag, bool enable){if (enable)_state |= tag;else_state &= ~tag;}// 指定的状态是否打开bool isStateEnable(int tag) const{return (_state & tag) != 0;}private:long long _state;};


热点排行