int test(int a) { return a; } typedef定義可以簡(jiǎn)化函數(shù)指針的定義,在定義一個(gè)的時(shí)候感覺(jué)不出來(lái),但定義多了就知道方便了,上面的代碼改寫(xiě)成如下的形式:#include <iostream> #include <string> using namespace std;
int test(int a) { return a; } 更多內(nèi)容請(qǐng)看C/C++技術(shù)專題專題,或 函數(shù)指針同樣是可以作為參數(shù)傳遞給函數(shù)的,下面我們看個(gè)例子,仔細(xì)閱讀你將會(huì)發(fā)現(xiàn)它的用處,稍加推理可以很方便我們進(jìn)行一些復(fù)雜的編程工作。 //-------------------該例以上一個(gè)例子作為基礎(chǔ)稍加了修改-----------------------------
#include <iostream> #include <string> using namespace std;