評價: 0 回應: 1 閱覽: 87
置頂

函式指標如何用template儲存?

各位好~

如題函式指標宣告如下
void (helloworld::*pf)() = &helloworld::funcA;
或是
int (helloworld::*pf2)(int a,int b) = &helloworld::funcB;

也就是儲存不同的引述與回傳值的function pointer

template要如何宣告?

熱門回應

有簡單的方法跟困難的方法,簡單的方法就是用typedef

比方說typedef bool (*SomeFunctionPt)(int, int);

再std::list<SomeFuntionPt>

困難的就...沒必要說了 XD 不知道你問的是不是這個

另外C++11的std::function也可以用

會員登入 (先登入會員才能回覆留言喔!)

Facebook留言