VC++ 定义了加、减、乘、除的消息函数,为什么乘号和除号不能使用呢?
voidCCalculator1Dlg::OnDivision(){//TODO:AddyourcontrolnotificationhandlercodehereUpd...
void CCalculator1Dlg::OnDivision()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1/m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnMinus()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1-m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnMultiplication()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1*m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnPlus()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1+m_num2;
UpdateData(FALSE);
}
编译有错误,如下:
D:\vcproject\calculator1\calculator1Dlg.cpp(184) : error C2676: binary '/' : 'class CString' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vcproject\calculator1\calculator1Dlg.cpp(200) : error C2676: binary '*' : 'class CString' does not define this operator or a conversion to a type acceptable to the predefined operator
执行 cl.exe 时出错.
calculator1.exe - 1 error(s), 0 warning(s) 展开
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1/m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnMinus()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1-m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnMultiplication()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1*m_num2;
UpdateData(FALSE);
}
void CCalculator1Dlg::OnPlus()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_result=m_num1+m_num2;
UpdateData(FALSE);
}
编译有错误,如下:
D:\vcproject\calculator1\calculator1Dlg.cpp(184) : error C2676: binary '/' : 'class CString' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vcproject\calculator1\calculator1Dlg.cpp(200) : error C2676: binary '*' : 'class CString' does not define this operator or a conversion to a type acceptable to the predefined operator
执行 cl.exe 时出错.
calculator1.exe - 1 error(s), 0 warning(s) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询