把函数指针作为某个函数的参数进行传递
#include <iostream>
using namespace std;
typedef int(*FunType)(int, int);//定义一个函数指针类型
int mf(int temp1, int temp2)
{
return 1;
}
void testfunc(int i, int j, FunType funcpoint)
{
int result = funcpoint(i, j);
cout << result << endl;
}
int main()
{
testfunc(3, 4, mf);
return 0;
}
1