switch的参数不能是string float?
#include<string>
#include<iostream>
using namespace std;
int main()
{
string ss;
cout<<"请出入串ss:"<<endl;
cin>>ss;
cout<<endl;
switch(string ss)
{
case "asd":
int *a=new int[2];
break;
case "zxc":
float *f=new float[2];
break;
}
return 1;
}
出现编译错误,听说是 switch的参数不能是 string,float 等类型,为什么哪?如何解决上述代码?