18
为什么switch语句不能应用于字符串?
编译以下代码,得到的错误type illegal。 int main() { // Compilation error - switch expression of type illegal switch(std::string("raj")) { case"sda": } } 您不能在switch或中使用字符串case。为什么?是否有任何解决方案可以很好地支持类似于打开字符串的逻辑?