c++里面函数也可以作为指针来传递
int sum(int a, int b)j{
return a+b;
}
void wrapper(int a, int b, int (*p)(int, int)){//*p 可以代表即将传入的函数,为函数指针
cout<<p(a, b)<<endl;
}
int main(){
wrapper(2, 3, sum);
int (*p)(int, int) = sum;
wrapper(2, 3, p);
}
参考:http://harttle.com/2015/07/05/cpp-pointers-and-references.html