随笔
enum SM_DBModifyOpt { eSM_DB_Add, eSM_DB_Update, eSM_DB_Del, }; char c = {0};//111---删除|更新|增加 bool IsOpt(int eOpt, char c) { return (c >> eOpt & 1) == 1; } void SetOpt(int eOpt, char& c) { c |= (1 << eOpt); } int main() { //SetOpt(eSM_DB_Add, c); SetOpt(eSM_DB_Update, c); SetOpt(eSM_DB_Del, c); bool b = IsOpt(eSM_DB_Add, c); b = IsOpt(eSM_DB_Update, c); b = IsOpt(eSM_DB_Del, c); return 0; }