#include <iostream>
using namespace std;
int sum(int x,int y){return x+y;}
int product(int x,int y){return x*y;}
int main()
{
int (*pf)(int ,int );
int a,b,result;
cout << "a="; cin >> a;
cout << "b="; cin >> b;
pf=sum; result=pf(a,b);
cout << a << "+"<< b<<"="<<result<< endl;
pf=product; result=pf(a,b);
cout << a << "*"<< b<<"="<<result<< endl;
return 0;
}
函数指针的简单应用
最新推荐文章于 2023-05-03 11:27:41 发布