1.枚举的定义
2.枚举的使用
#include <iostream>
#include <string>
using namespace std;
/*
* 1.枚举的定义
* 2.枚举的使用
* */
enum class Gender{man,women};
class stu{
public:
string name;
int age;
Gender gender;
stu(string name,int age,Gender gender):name(name),age(age),gender(gender){
cout<< "有参构造"<<endl;
}
~stu(){
cout << "无参构造"<<endl;
}
};
int main() {
enum class color{red,yello,green};
enum fruits{banana,apple,orange};
cout << (int)color::red << endl;
cout << apple<<endl;
stu s("小明",18,Gender::man);
return 0;
}