The C++ Switch statement doesn’t actually work on strings, for example the following code would generate a compiler error (VC++ C2450):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
std::string s = "bleh";
 
switch( s )
{
case "dude":
(…);
break;
case "hello":
(…);
break;
case: "bleh":
(…);
break;
}

Well I say, that’s a bit of a sticky wicket. So why not just resort to an if/then/else stream? Because I wanted to use the switch statement [...]