I have a basic enum
declaration:
enum Title {Prof, Dr, Mr, Mdm, Mrs, Miss, NA};
I've managed to map the user input from 0
to 5
with value from enum list respectively:
std::map<std::string,Title> m;
m["0"] = Prof;
m["1"] = Dr;
m["2"] = Mr;
m["3"] = Mdm;
m["4"] = Mrs;
m["5"] = Miss;
m[???] = NA; // What should I do here
std::string stitle;
cout << "\n" << "Title (0:Prof 1:Dr 2:Mr 3:Mdm 4:Mrs 5:Miss Any:NA): ";
cin >> stitle;
Title title = m[stitle];
How can I map the user input such as 6
, 7
or any input beside 0
to 5
with NA
value from the enum list?