首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这是什么东东

2012-02-13 
这是什么错误void CProDlg::OnOK(){// TODO: Add extra validation here//CDialog::OnOK()int posselect

这是什么错误
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:
//...
}

热点排行