在班上枚举?正确声明和使用

时间:2019-05-28 18:46:38

标签: c++ class enums

我很困惑如何在类的公共部分内声明枚举,如何在私有内部创建变量,并通过公共方法使用该变量。下面是代码,请您提供适当的声明来帮助我。

class Example {
private:
std::string name;
Example::Age variable; //I dont know if this is okay
public:
enum Age{Young,Old};
Example(std::string nam,variable a) : name(nam) {
a=Young; //I dont know if this is okay
}
..... 
};

0 个答案:

没有答案
相关问题