请各位来解释一下
#include <iostream>
#include<string>
using namespace std;
void main()
{
string str = "test";
switch(str)
{
case "test":
cout<<"test"<<endl;
default:
cout<<"default"<<endl;
}
}
--------------------Configuration: bicen - Win32 Debug--------------------
Compiling...
test.cpp
D:\projects\bicen\test.cpp(12) : error C2450: switch expression of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\projects\bicen\test.cpp(13) : error C2051: case expression not constant
D:\projects\bicen\test.cpp(17) : warning C4065: switch statement contains 'default' but no 'case' labels
Error executing cl.exe.
bicen.exe - 2 error(s), 1 warning(s)