【问题标题】:Visual C++ Opening a second formVisual C++ 打开第二个表单
【发布时间】:2012-07-28 12:08:04
【问题描述】:

我有一个项目包含两个表单,Form1.h 和 Form2.h。

每个的.cpp文件是test.cpp和Form2.cpp。

我想通过单击按钮从第一个表单打开第二个表单,我已经有代码,放置在 button1_Click 方法中:

Form2 ^ form = gcnew Form2;
form->Show();

我还在 Form1.h (#include "Form2.h") 中放置了包含文件,但是我不断收到以下错误:

error C2065: 'Form2' : undeclared identifier

error C2065: 'form' : undeclared identifier

error C2061: syntax error : identifier 'Form2'

error C2065: 'form' : undeclared identifier

error C2227: left of '->Show' must point to class/struct/union/generic type

1>          type is ''unknown-type''

1>  Generating Code...

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我这几天一直在寻找解决方案……但都没有奏效。 任何帮助将不胜感激。

【问题讨论】:

    标签: forms visual-c++ button


    【解决方案1】:

    您是否在 test.cpp 中包含了 Form1.h?

    【讨论】:

    • 你真的在头文件中声明了类吗?或者是在cpp中完成的。
    • 除了#include 语句和button1_Click 方法之外,我没有对源代码进行任何修改。
    • 向我们展示 Form2.h 包含的内容。它应该声明 Form2 类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多