2014-01-10 40 views
0

我在Form1中有一個名爲AUTO的變量,我想以名爲RoomStack的形式使用它。使用不同形式的變量

RoomStack.h聲明如下:

static Form1 ^FM = gcnew Form1(); 

(所以後來我就喜歡寫東西FM->AUTO

但聲明是給錯誤:

error C2143: syntax error : missing ';' before '^' 
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
error C3845: 'myUI::RoomStack::FM': only static data members can be initialized inside a ref class or value type 

請注意,我遇到這個問題之前和相同的方法工作。 我有一個名爲NewGame形式,它包含了一個變量,我想在Form1使用,所以在Form1.h我宣佈:

static NewGame ^NG = gcnew NewGame(); 

,它編譯。

爲什麼我現在有錯誤?

回答

0

Form1.h應包括在RoomStack.h

即添加以下行中RoomStack.h解決了這個問題:

#include "Form1.h"