for a small number of strings you can do this:
string s = "Feb";
unsigned int * ip = (unsigned int*)&s[0];
cout << *ip << endl; //find out what the number is
...
case 73421: //whatever the above number was goes here
with some legwork. Turn each string into its integer.
name each integer with an enum.
use the enum name and you get
switch Feb: //note the lack of quotes, its an int constant now
this isnt portable, so if you change OS the integers change, so it is of very limited value but its extremely fast. If you want it to be portable, use a portable algorithm to hash the string into an integer. Most hash functions are much slower than just the raw bytes repurposed to int.
* you probably need to pad short strings with the zero character until you get to sizeof int (which is probably 4, or use 64 bit, then it is 8).
eg string feb = "Feb\0\"; Its kind of a hacky way to do it...
here is a link to an old function I wrote that does this as well. (scroll down to my post)
http://cplusplus.com/forum/general/268492/
its large but its just a lookup table of integers and a small for loop. Its pretty quick.
------------------
or you can do a redesign.
int rates[] = {0,744,672,...}//put all 12 months in, skipping month 0 to start at 1 for convention
have user enter month in number not string, eg 1 for jan, 2 for feb, etc
check is from 1 to 12 and complain if not, then:
return rates[input];
if you can't use the numbers, the map mentioned above is the correct modern approach. I am just giving you a workaround because you asked for it, and it may be useful to know that you can indeed turn strings into numbers (and someday you likely will have to do this) when there is a need.