[問題] 函式指標再一問..

看板C_and_CPP (C/C++)作者 (是黑是白)時間15年前 (2011/02/24 20:45), 編輯推噓1(104)
留言5則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) DEV C++ 問題(Question): 函式指標+typedef的使用方式 有warning 錯誤結果(Wrong Output): [Warning] initialization from incompatible pointer type 程式碼(Code): #include<stdio.h> #include<stdlib.h> void func(int a,int b) { printf("%d\n%d",a,b); } int main() { typedef (*pfuntype)(int,int); pfuntype newfunc = func; newfunc(2,4); system("pause"); return 0; } 補充說明(Supplement): 之前有問過函式指標的用法了 大致上了解~ 但加上typedef卻一直有警告產生... 問同學都沒下文= =" 請幫忙解惑一下Orz 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.243.66

02/24 20:49, , 1F
你的 return type 呢?
02/24 20:49, 1F

02/24 20:54, , 2F
return type加進去就OK了!!
02/24 20:54, 2F

02/24 20:55, , 3F
感謝L大~
02/24 20:55, 3F

02/25 11:43, , 4F
typedef void(*pfuntype)(int,int);
02/25 11:43, 4F

11/09 22:36, , 5F
不知道從什麼時候開始美君變成很重要的人
11/09 22:36, 5F
文章代碼(AID): #1DPbC3kx (C_and_CPP)
文章代碼(AID): #1DPbC3kx (C_and_CPP)