[問題] Windows form全域變數

看板C_and_CPP (C/C++)作者 (aki)時間10年前 (2016/01/12 11:44), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
開發平台(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

01/12 21:06, , 1F
int i沒宣告成static
01/12 21:06, 1F

02/22 21:51, , 2F
一般來說這類問題我會用extern來處理
02/22 21:51, 2F
文章代碼(AID): #1Mb7QxdR (C_and_CPP)
文章代碼(AID): #1Mb7QxdR (C_and_CPP)