#include <iostream>
using namespace std;
int add(int x, int y) {
return x + y;
}
int sub(int x, int y) {
return x - y;
}
//函数指针
int (*fun)(int x, int y);
int main(int argc, char *argv[]) {
//第一种写法
fun = add;
cout << "(*fun)(1,2) = " << fun(1, 2);
//第二种写法
fun = ⊂
cout << "(*fun)(5,3) = " << (*fun)(5, 3) << fun(5, 3);
}
11-22
463
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交