[問題] bcb include問題

看板C_and_CPP (C/C++)作者 (小黑要乖喔)時間16年前 (2009/05/20 16:59), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
有一個很基本中的基本的問題, 但我真的沒辦法解決, 語言:BCB 6.0 假設我unit1.cpp裡面要運作 class practice3{ virtual void open()=0; virtual void print()=0; virtual void close()=0; public:void display() { open(); for(int i=0;i<5;i++) print(); close(); } }; void __fastcall TForm1::Button1Click(TObject *Sender)//運作 { chardisplay1 pc3; String st; st=Edit1->Text; pc3.chardisplay(st); pc3.display(); RichEdit1->Text=test; } //--------------------------------------------------------------------------- unit2裡面要運作 class chardisplay1:public practice3 { String ch1; public:chardisplay(String ch) { ch1=ch; return 0; } virtual void open() { test+="<<"; } virtual void print() { test+=ch1; } virtual void close() { test+=">>"; } }; 程式是能運作,但是我不知道怎麼取出test裡的值(在unit1裡), 其實就算不把這兩段程式分成兩個unit寫, 我依樣取不出test的值, 如果test是int我還能return, 但他是string的時候我就不知道該怎麼得到test的值 煩請高手幫忙解答,感謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.200.188

05/20 23:15, , 1F
將String test宣告在unit2的pubilc下
05/20 23:15, 1F

05/20 23:16, , 2F
打錯是public 然後在unit1中 使用pc3.test來取值
05/20 23:16, 2F

05/21 10:24, , 3F
3q
05/21 10:24, 3F
文章代碼(AID): #1A4yPqYo (C_and_CPP)
文章代碼(AID): #1A4yPqYo (C_and_CPP)