我复制
if ((MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == DialogResult::No))
{
// cancel the closure of the form.
Application::Exit();
}
来自msdn。在我编译的地方我有
1> ------ Build build:项目:test2,配置:调试Win32 ------ 1 GT;测试2.cpp 1> c:\ users \kredkołamacz\ documents \ visual studio 2010 \ projects \ test2 \ test2 \ Form1.h(103):错误C2039:'否':不是'System :: Windows :: Forms ::的成员表:: DialogResult的” 1 GT; c:\ users \kredkołamacz\ documents \ visual studio 2010 \ projects \ test2 \ test2 \ Form1.h(16):查看'System :: Windows :: Forms :: Form :: DialogResult'的声明 1> c:\ users \kredkołamacz\ documents \ visual studio 2010 \ projects \ test2 \ test2 \ Form1.h(103):错误C2065:'否':未声明的标识符 ==========构建:0成功,1个失败,0个最新,0个跳过==========
怎么了?如何解决这个问题?
答案 0 :(得分:7)
我很难过但是DialogResult
的MSDN文章在C ++示例中提到类型名称应该以{{1}}为前缀以使其非嵌套。也许试试这个:
::
(我也删除了多余的括号......)
如果没有帮助,请尝试指定完整的命名空间,即if (MessageBox::Show(
"Are you sure that you would like to close the form?",
"Form Closing", MessageBoxButtons::YesNo,
MessageBoxIcon::Question) == ::DialogResult::No)
,看看它是否有效。