2012-07-30 63 views
0

我有一個包含兩個窗體Form1.h和Form2.h的項目。Visual C++打開第二個表單

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

我想通過點擊一個按鈕,其中我已經爲代碼,放置在的button1_Click方法內以打開從第一第二形式:

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

我人還放置包含文件Form 1中.H(#包括「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 ========== 

我一直在尋找一個解決方案,一兩天......其中沒有工作過。 任何幫助,將不勝感激。

回答

0

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

+0

是的!忘了提到這一點。 – user1435947 2012-07-30 19:18:23

+0

當然你的意思是Form2.h? – 2012-07-30 19:18:31

+0

將test.cpp中的#include「Form1.h」切換爲#include「Form2.h」導致:C2061:語法錯誤:標識符'Form1'包含兩者都會導致相同的問題。 – user1435947 2012-07-30 19:20:52

相關問題