C++ 枚举类

1_枚举类.cpp

#include<iostream>
//枚举类是带有类类型特征的枚举类型
using namespace std;
enum class COLOR {RED,BLUE,GREEN};
        //default: RED=0; BLUE=RED+1;...

class Book_bag{
    public:
     COLOR color;   //0:red,1:blue,2:green
};

int main()
{
    Book_bag b;
    b.color = COLOR::RED;
}
posted @ 2016-03-30 14:02  夜色下的港湾  Views(111)  Comments(0Edit  收藏  举报