标签:
int add(int a,int b){ return a+b; }
第一种,c语言通用。定义一个process_job函数指针类型,返回值为 int ,函数参数为int a,int b。使用用两种方法。
typedef int (*process_job)(int a,int b); process_job a; a = add;
cout << a(10,12) << endl;
cout << (*a)(10,12) << endl; //OK
第二种,C++。使用,只有一种方法。
#include <functional> typedef function< int(int,int)> task; task t = add; cout << t(22,23) << endl; // cout << (*t)(22,23) << endl; error
标签:
原文地址:http://www.cnblogs.com/cycxtz/p/4757075.html