[問題] 關於BCB物件(Label)陣列的問題

看板C_and_CPP (C/C++)作者 (D2000用戶)時間12年前 (2013/08/30 16:08), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) BCB 問題(Question): 請問BCB物件陣列的問題 想請問如何將物件Label做成陣列 在網路上找了一些方法 但有很多都是動態創造元件的 可是我之前已經把20個Label物件都已經拉好也修改過Caption了 請問該怎麼做才能把Label_1~20做成陣列呢? 有試過 1.在.h檔裡宣告 TLabel* TestLab[]={Label_1,Label_2,Label_3,.......,Label_20}; 2.在.h檔裡宣告 TLabel* TestLab 然後在.cpp裡 void __fastcall Form1::FormCreate(TObject *Sender) { int i; for(int i=0; i<20; i++) { TestLab[i] = new TLabel(this); TestLab[i]->Parent = FormName; } 這兩個方法好像是不可行的 所以想跟各位前輩請教該怎麼做才能將物件弄成陣列 感激不盡 錯誤結果(Wrong Output): Incorrect method declaration in clsaa TForm1 class -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.66.174.13

08/30 18:27, , 1F
TLabel *TestLab[20];
08/30 18:27, 1F

08/30 18:30, , 2F
TestLab[0] = Label_1;
08/30 18:30, 2F

08/30 18:46, , 3F
請問這是寫在hearder檔還是cpp檔
08/30 18:46, 3F
文章代碼(AID): #1I85CEM5 (C_and_CPP)
文章代碼(AID): #1I85CEM5 (C_and_CPP)