这是什么错误
void CProDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
int pos=select.GetCurSel();
UpdateData(true);
CString str;
select.GetLBText(pos,str);
MessageBox(str);
switch(str)
{
case "+":
{
text3=text1+text2;
}break;
case "-":
{
text3=text1-text2;
}break;
case "*":
{
text3=text1*text2;
}break;
case "/":
{
text3=text1/text2;
}break;
}
UpdateData(false);
}
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(190) : error C2450: switch expression of type 'class CString' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(191) : error C2051: case expression not constant
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(198) : error C2051: case expression not constant
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(206) : error C2051: case expression not constant
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(213) : error C2051: case expression not constant
D:\[大家网]Visual.C++.6.EN[www.TopSage.com]\MSDev98\MyProjects\pro\proDlg.cpp(221) : warning C4060: switch statement contains no 'case' or 'default' labels
Error executing cl.exe.
pro.exe - 5 error(s), 1 warning(s)
[解决办法]
switch(str.GetAt(0))
{
case '+':
//...
break;
case '-':
//...
break;
case '*':
//...
break;
case '/':
//...
break;
default:
//...
}