My otherwise detailed assignment prompt has a sentence in the middle reading
"Use an enumerated data type for the menu item selection"
The trouble is I can't figure out how to take user input as enumerated data.
I pictured it something like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
enum menu
{
FIRST
SECOND
THIRD
};
menu choice;
cin >> choice;
if (choice==FIRST)
cout << "You've chosen first";
else if (choice==SECOND)
cout << "You've chosen second";
else if (choice==THIRD)
cout << "You've chosen third";
|
This is rough obviously, but I thought the idea was simple enough, though I failed to realize you can't simply throw any data type into an enumeration, and this failure has me doubting what the assignment is actually asking me to do.
I assumed it is asking for a string, and will compare that to the menu options, which I could just as easily do without the use of enumerations at all. Also, I know that I can simply check the input, assign an int, and check that int against the enumerations, but again this leaves me wondering whats the point of using enum in the first place?
Is this just a superfluous test to see if I can shoehorn needless enumerations into a program, or is there something I'm missing? Please help.