编译以下代码并得到错误type illegal.
int main()
{
// Compilation error - switch expression of type illegal
switch(std::string("raj"))
{
case"sda":
}
}
Run Code Online (Sandbox Code Playgroud)
你不能在任何一个switch或中使用字符串case.为什么?是否有任何解决方案可以很好地支持类似于切换字符串的逻辑?