クラスの/の列挙型データ型があります。私は内部のメインからその値を設定/割り当てたい。私のコードは、私が独自の名前と種とペットのセットそれぞれを作成するために、ベクターを使用しています私のメイン関数内配列enumsと入力
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"を宣言しましたが、ユーザーはその問題を解決するために値 –