//#include "stdafx.h"
#include <iostream>
using namespace std;
int function(int a, int b)
{
cout << a << " + " << b << " = ";
return a + b;
}
int main()
{
int (*tp)(int, int);
tp = &function;
cout << tp(1, 0) << endl;
typedef int(type_func)(int, int);
type_func *tp1; //定义指向函数的指针
tp1 = &function;
//tp1 = function; //or C版本
cout << tp1(1, 1) << endl;
typedef int(*type_p_func)(int, int);
type_p_func tp2;
tp2 = &function;
cout << tp2(1, 2) << endl;
system("pause");
return 0;
}
函数指针基础语法C++
最新推荐文章于 2024-01-12 14:28:53 发布