VC++窗口化中确定按钮进行代码添加时出现错误,初学者求大神指导
代码为:voidCOneDlg::OnOK(){dlg1test;intresult=test.DoModal();if(result==IDok)AfxMessageB...
代码为:
void COneDlg::OnOK()
{
dlg1 test;
int result=test.DoModal();
if(result==IDok)
AfxMessageBox("单击确定按钮");
else
AfxMessageBox("单击取消按钮");
CDialog::OnOK();
}
错误为:
oneDlg.cpp(174) : error C2065: 'dlg1' : undeclared identifier
oneDlg.cpp(174) : error C2146: syntax error : missing ';' before identifier 'test'
oneDlg.cpp(174) : error C2065: 'test' : undeclared identifier
oneDlg.cpp(175) : error C2018: unknown character '0xa3'
oneDlg.cpp(175) : error C2018: unknown character '0xa8'
oneDlg.cpp(175) : error C2018: unknown character '0xa3'
oneDlg.cpp(175) : error C2018: unknown character '0xa9'
oneDlg.cpp(175) : error C2228: left of '.DoModal' must have class/struct/union type
oneDlg.cpp(176) : error C2065: 'IDok' : undeclared identifier
oneDlg.cpp(177) : error C2018: unknown character '0xa3'
oneDlg.cpp(177) : error C2018: unknown character '0xbb'
oneDlg.cpp(178) : error C2143: syntax error : missing ';' before 'else'
oneDlg.cpp(179) : error C2018: unknown character '0xa3'
oneDlg.cpp(179) : error C2018: unknown character '0xbb'
oneDlg.cpp(180) : error C2143: syntax error : missing ';' before 'tag::id'
执行 cl.exe 时出错. 展开
void COneDlg::OnOK()
{
dlg1 test;
int result=test.DoModal();
if(result==IDok)
AfxMessageBox("单击确定按钮");
else
AfxMessageBox("单击取消按钮");
CDialog::OnOK();
}
错误为:
oneDlg.cpp(174) : error C2065: 'dlg1' : undeclared identifier
oneDlg.cpp(174) : error C2146: syntax error : missing ';' before identifier 'test'
oneDlg.cpp(174) : error C2065: 'test' : undeclared identifier
oneDlg.cpp(175) : error C2018: unknown character '0xa3'
oneDlg.cpp(175) : error C2018: unknown character '0xa8'
oneDlg.cpp(175) : error C2018: unknown character '0xa3'
oneDlg.cpp(175) : error C2018: unknown character '0xa9'
oneDlg.cpp(175) : error C2228: left of '.DoModal' must have class/struct/union type
oneDlg.cpp(176) : error C2065: 'IDok' : undeclared identifier
oneDlg.cpp(177) : error C2018: unknown character '0xa3'
oneDlg.cpp(177) : error C2018: unknown character '0xbb'
oneDlg.cpp(178) : error C2143: syntax error : missing ';' before 'else'
oneDlg.cpp(179) : error C2018: unknown character '0xa3'
oneDlg.cpp(179) : error C2018: unknown character '0xbb'
oneDlg.cpp(180) : error C2143: syntax error : missing ';' before 'tag::id'
执行 cl.exe 时出错. 展开
2个回答
展开全部
你要学会按照错误提示查找错误。比如 'dlg1' : undeclared identifier意思是dlg1这个类型未识别,你应该忘了添加头文件#include "dlg1.h", 比如syntax error : missing ';' before 'else'说你的else前面缺少分号,可是你已经有了啊,原来你的分号是在中文输入法下输入的,是错误的 ;和;的区别 在比如syntax error : missing ';' before 'tag::id'一看就是IDOK你错写成IDoK,你要细心点
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询