#include <iostream>
using namespace std;
int fa(int a,int b)
{
return a+b;
}
int fb(int a,int b)
{
return a*b;
}
int fc(int a,int b)
{
return a-b;
}
int g(int a,int b, int(* f)(int a ,int b))
{
return f(a,b);
}
int main(int argc, char *argv[])
{
cout<<g(3,4, fa)<<endl;
cout<<g(3,4,fb)<<endl;
cout<<g(3,4,fc)<<endl;
return 0;
}
c++ 函数作为参数, 参数是函数
最新推荐文章于 2024-08-18 22:34:12 发布