2014-01-10 37 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"