C++函式指標的運用及使用JAVA的替代方法
最近同事幫新進同事講解函式指標的妙用,在這裡做一下心得及替代方法比較 C & C++ 函式指標 語法: type (*functionname)([type],..) -> 回傳型態 (*函式名稱)(參數,..) 例: #include "stdafx.h" #include using namespace std; void printA(){ cout << "printA" << endl; } void printB(){ cout << "printB" << endl; } void printC(){ cout << "printB" << endl; } int _tmain(int argc, _TCHAR* argv[]) { void (*printValue[3])(); printValue[0] = printA; printValue[1] = printB; printValue[2] = printC; for( int i=0 ; i printValue[i](); ...