How can I accept values from a terminal or console to update the_sex value and how can I enter a value for a variable the_sex?
The input can be represented by any one you want: an integer (1 for men, 2 for women), a char('M' for men, 'F' for women), a std::string. Here is the sample code for the version char:
char in;
std::cin >> in;
switch (in) {
case 'M':
the_sex = MALE;
break;
case 'F':
the_sex = FEMALE;
break;
default:
break;
}
or, here is the version std::string:
std::string in;
std::cin >> in;
if (in == "MALE") the_sex = MALE;
else if (in == "FEMALE") the_sex = FEMALE;
else
the_sex ?
switch SEX:
std::ostream& operator<<(std::ostream& os, SEX the_sex) {
switch (the_sex) {
case MALE:
os << "MALE";
break;
case FEMALE:
os << "FEMALE";
break;
}
return os;
}