枚举的用法

类内定义

class Demo{
    public:
        enum COLORTYPE{RED,GREEN,BLUE,YELLOW,BLACK,WRITH};
}
// 在类外使用
cout<<Demo::RED<<endl;

类外定义

enum COLORTYPE{RED,GREEN,BLUE,YELLOW,BLACK,WRITH};
class Demo{
    public:   
}
// 在类外使用
cout<<COLORTYPE::RED<<endl;

posted on 2021-06-11 23:34  lodger47  阅读(25)  评论(0)    收藏  举报

导航