0
我有一个枚举数据类型为/在一个类中。我想从主内部设置/赋值。我的代码看起来像数组枚举和输入
class pet
{
public:
enum species { bird,cat,dog,rat,horse };
enum demands { food,water,companionship };
demands demand;
species petSpecies;
float waterLevel = 100;
float foodLevel = 100;
float Happiness = 100;
//Species are not initialized in the class and have to be initialized separately in main
string name;
//And a bunch of functions here and there
};
里面我主要的功能,我使用向量来创建一个集中的每个宠物都有自己的名称和种类。证明困难的是给宠物设置一个物种。
我该怎么做?
如何做到“cin” –
你是什么意思? @SuhridMulay – RomMer
我宣布了一个变量“pet :: species spe”,现在用户必须输入解决该 –