Почему оператор switch нельзя применить к строкам? ⇐ C++
-
Anonymous
Почему оператор switch нельзя применить к строкам?
Compiling the following code gives the error message: type illegal.
int main() { // Compilation error - switch expression of type illegal switch(std::string("raj")) { case"sda": } } You cannot use string in either switch or case. Why? Is there any solution that works nicely to support logic similar to switch on strings?
Источник: https://stackoverflow.com/questions/650 ... to-strings
Compiling the following code gives the error message: type illegal.
int main() { // Compilation error - switch expression of type illegal switch(std::string("raj")) { case"sda": } } You cannot use string in either switch or case. Why? Is there any solution that works nicely to support logic similar to switch on strings?
Источник: https://stackoverflow.com/questions/650 ... to-strings
Мобильная версия