作者skitty (aki)
看板C_and_CPP
標題[問題] Windows form全域變數
時間Tue Jan 12 11:44:56 2016
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
c++2010 Windows form
問題(Question):
我想要宣告一個全域用的變數和陣列
上網查資料在.h檔試了以下幾種:
1. Form1 底下宣告 int i
2. Form1底下宣告 int A[10]
3. Form1底下宣告 array<int^>^ Arry= gcnew array<int^>(10)
4. namespace底下宣告
public class A{
public: static int a1;
static int b1[10];
};
但是在.cpp檔main中都無法呼叫
ex 打Form1::i會說是不合法的
想請問是我宣告有誤還是呼叫有誤…
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.182.196
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1452570299.A.9DB.html
推 kwpn: int i沒宣告成static 01/12 21:06
→ makubex49: 一般來說這類問題我會用extern來處理 02/22 21:51