Page 1 of 1

c++ switch?

Posted: Fri Jul 17, 2009 11:27 am
by John Adams
Kinda exposing my noobness a little... This is kinda a rhetorical question, cuz I actually googled it and discovered...

C++'s "switch(var)" can only use int constants? How lame!!

I was trying to check item_type...

Code: Select all

					switch(item_type)
					{
						case "Normal":
							// stuff
							break;
						case "Armor":
							// stuff
							break;
						case "Spell":
							// stuff
							break;
					}
and being yelled at that "error C2051: case expression not constant" :( :(

I know I ran into this before, but forgot. So, just venting. Back to if/then/else blah...

I can do this in PHP gdi!! ;)