Click to See Complete Forum and Search --> : Can "switch" based on std::string?


warrener
February 19th, 2008, 05:45 PM
string x = "test1";
switch(x){
case "test1" : break;
case "test2" : break;
default : break;
}

Why this don't work for string?

bovinedragon
February 19th, 2008, 05:50 PM
you cant use switch with string, however you could write your own switch if you really wanted to

from google: http://www.codeguru.com/Cpp/Cpp/cpp_mfc/article.php/c4067