I would like to use an enum
value for a switch
statement. Is it possible to use the enum
values enclosed in \"{}\"
as cho
i had a similar issue using enum with switch cases later i resolved it on my own....below is the corrected code, perhaps this might help.
//Menu Chooser Programe using enum
#include
using namespace std;
int main()
{
enum level{Novice=1, Easy, Medium, Hard};
level diffLevel=Novice;
int i;
cout<<"\nenter a level: ";
cin>>i;
switch(i)
{
case Novice: cout<<"\nyou picked Novice\n"; break;
case Easy: cout<<"\nyou picked Easy\n"; break;
case Medium: cout<<"\nyou picked Medium\n"; break;
case Hard: cout<<"\nyou picked Hard\n"; break;
default: cout<<"\nwrong input!!!\n"; break;
}
return 0;
}