Почему оператор switch нельзя применить к строкам? ⇐ C++
Почему оператор 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
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Встроенный оператор «<<» нельзя применить к операнду типа «std::ostream» [закрыто]
Anonymous » » в форуме C++ - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-