做了一个简单的运算器程序,两个编辑框控件,变量分别为m_a,m_b;四个单选按钮控件,分别代表+ ,_,*,/;一个显示结果的静态控件,变量为m_c;一个静态控件,代表=;编译时出现下面一行错误:
left of '.Format' must have class/struct/union type
为 +,-,*,/ 按钮控件添加的代码分别如下:其中红色部分为添加的代码。
void CXinDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData();
double m_c=m_a+m_b;
m_c.Format("%10.3f",c);
UpdateData(FALSE);
}
void CXinDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
UpdateData();
double m_c=m_a-m_b;
m_c.Format("%10.3f",c);
UpdateData(FALSE);
}
void CXinDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
UpdateData();
double m_c=m_a*m_b;
m_c.Format("%10.3f",c);
UpdateData(FALSE);
}
void CXinDlg::OnRadio4()
{
// TODO: Add your control notification handler code here
UpdateData();
double m_c=m_a/m_b;
m_c.Format("%10.3f",c);
UpdateData(FALSE);
}