enum在类中使用
class EnumTest {
public:
EnumTest();
~EnumTest();
enum Type
{
TYPE_A =0,
TYPE_B,
TYPE_C
};
enum class task_state
{
PREPARE,
QUEUE,
RUNNING,
STOP,
COMPLETED,
FAILED,
DELETED,
PAUSE,
PAUSING,
CANCEL,
CANCELING
};
};
int main() {
//
EnumTest::Type type = EnumTest::TYPE_B;
switch (type) {
case EnumTest::TYPE_A:
qDebug()<<"TYPE_A";
break;
case EnumTest::TYPE_B:
qDebug()<<"TYPE_B";
break;
case EnumTest::TYPE_C:
qDebug()<<"TYPE_C";
break;
default:
break;
}
//
int ret = static_cast<int>(EnumTest::task_state::QUEUE);
return 0;
}