[問題] 轉型成Object以後...

看板C_and_CPP作者 (囧)時間14年前 (2011/11/17 01:23), 編輯推噓0(005)
留言5則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Visual studio 2010 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) NO 問題(Question): 將原本的類別轉型成Object檔案後 無法呼叫原先類別中的method 餵入的資料(Input): 預期的正確結果(Expected Output): 可以呼叫到原本的method 錯誤結果(Wrong Output): error C2039 : 'set' :不是'System::Object'的成員 程式碼(Code):(請善用置底文網頁, 記得排版) void detect(Object^f1) { // set為原本Form1中的一個方法 這次的問題是希望能夠重新呼叫道set f1->set(10); } int main() { Form1 ^f1 = gcnew Form1(); Thread ^dt = gcnew Thread(gcnew ParameterizedThreadStart(&detect)); dt->Start(f1); // 如果將set放在此 不會有錯誤 //f1->set(10); } 麻煩各位大大了(鞠躬 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 192.192.199.49

11/17 01:26, , 1F
((Form1 ^)f1)->set(10);
11/17 01:26, 1F

11/17 01:31, , 2F
感謝大大 可以了Q_Q 可以回家睡覺了
11/17 01:31, 2F

11/17 10:19, , 3F
^那是什麼東西啊...沒看過= =
11/17 10:19, 3F

11/17 10:21, , 4F
to樓上: google C++/CLI
11/17 10:21, 4F

11/17 10:22, , 5F
原來不是單純c++...
11/17 10:22, 5F
文章代碼(AID): #1Em_6Hvj (C_and_CPP)