Definetely better using enum than int, was just not thinking.
make_pair can be found here
But yes, map doesn't replace your program. Should you use map in your program? It would have saved you probably time.
I think people are mentioning map because it offers a way for the programmer to do quite easily what your program in the first place. Obviously, it is better to offer yourself a way to do this than use any other external program. So somebody could do
Code:
enum day{
Monday,
Tuesday,
...
};
...
map<string,int> dayStr;
dayStr.insert(par<string,int>(Monday, "Monday");
dayStr.insert(par<string,int>(Tuesday, "Tuesday");
...
day today = Monday;
cout << dayStr[Monday] << endl;
cout << dayStr[today] << endl;
So he would be able to easily get the string.
You could make a library with macros. But I cannot get my head of how to make this elegant for the users! But I am sure there is a way so the user can just type
Code:
DECL_ENUM(day)
ENUM(Monday)
...
END_ENUM
and there will be an enum generated as well as an array of strings and finally a dayStr() function to get the appropriate string value.