Image

Imageenamoring wrote in Imagecpp

just a quick question.

for a project I'm doing, I'm using a structure array, animal, and one of the members is of the enumerated type genderType. for some reason, i am not able to take input and store it in array[num].gender (I'm passing the array to a function, btw.) any suggestions? here's the code.


enum genderType {male, female, neutered, spayed};

struct animal{ //Stats for all the basic info about the animal stored in the kennel.
string species;
string name;
string breed;
int age;
float weight;
genderType gender;
int kennelNum;

animal(string br = "mutt", int a = -1)
{
breed = br;
age = a;
}

};




void addAnimal(animal array[], int &num)
{

cout << endl << "Please enter a name for the animal: ";
cin >> array[num].name;
cout << endl << "Enter " << array[num].name << "'s age: ";
cin >> array[num].age;
cout << endl << "Enter " << array[num].name << "'s weight: ";
cin >> array[num].weight;
cout << endl << "Enter " << array[num].name << "'s breed: ";
cin >> array[num].breed;
cout << endl << "Tell us, what kind of animal is " << array[num].name << "? ";
cin >> array[num].species;
do{
cout << endl << "Please enter a gender (male, female, spayed, or neutered): ";
cin >> array[num].gender;
}while(!array[num].gender);


array[num].kennelNum = num + 1;
cout << array[num].name << " was placed in Kennel " << array[num].kennelNum;
num++;
}