Re: [問題] 請教 Function Pointer 的觀念

看板C_and_CPP (C/C++)作者 (星空下的鮪魚)時間16年前 (2009/03/07 07:50), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串3/4 (看更多)
※ 引述《sawang (New Friends)》之銘言: : ※ 引述《jimmy2266 (2266)》之銘言: : : 為什麼不能 bool (*compare) 就好?? : 這樣沒有宣告你要的函數需要幾個parameters : : 為什麼不能 bool *compare( int, int ) ?? : 這樣那個*號變成是跟bool連在一起的,表示回傳值是指向bool型態的指標 : 而不是表示compare是function pointer : : 為什麼不能 bool compare( int, int ) ?? 來補個問題好了 我看過的程式碼 int foo (int , int , void ( func)(void *, const DWORD) ); int foo1 (int , int , void ( *func)(void *, const DWORD) ); foo和foo1裡面的func傳入的東西都是一樣,都是一個callback function。 foo1裡的func應該是function pointer,因為他多一個*,而且手頭上能找到的 function pointer都是長的像foo1的那副德性。 那foo的func又是什麼東西? 感覺像是pass by value。 -- 或許人生是一段整合內在的自己 並尋求人間一點真情的過程吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.115.240.57 ※ 編輯: aecho 來自: 59.115.240.57 (03/07 07:50)

03/07 21:21, , 1F
妳這樣提出來 我也想問一下裡面的 (void *,... ) 是代表
03/07 21:21, 1F

03/07 21:21, , 2F
傳什麼過去??
03/07 21:21, 2F
文章代碼(AID): #19iRR0gH (C_and_CPP)
文章代碼(AID): #19iRR0gH (C_and_CPP)