#include<iostream>
#include <bitset>
using namespace std;
typedef int(*func)(int, int);
//函数指针类型,func代表这样一个函数类型:返回值是int的带有两个int参数的函数
int add(int a, int b)
{
return a + b;
}
void test(int (*testFunc)(int, int))
{
cout<<testFunc(10,100)<<endl;
}
int main()
{
func b = add;
cout << b(3, 4) << endl;
int (*a)(int, int) = add;
cout << a(4,9) << endl;
test(add);
test(b);
test(a);
return 0;
}
函数指针 代码测试
最新推荐文章于 2022-08-13 20:06:20 发布