函数指针三种形式

版权声明:所有博客均由作者本人原创,若要转载,请注明出处。谢谢 https://blog.csdn.net/LU_Leo/article/details/82470108
#include <iostream>
using namespace std;
int func(int , int)
{
	cout << "func" << endl;
    return 0;
}
typedef int (MY_FUNC)(int, int);//第一种
typedef int(*MY_FUNC_P)(int, int);//第二种
int main()
{
    int a=10 , b=10;
	MY_FUNC *fp1 = NULL;
	fp1 = func;
	fp1(a, b);
	MY_FUNC_P fp2 = func;
	fp2(a, b);
	int(*fp3)(int, int) = NULL;//第三种
	fp3 = func;
	fp3(a, b);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/LU_Leo/article/details/82470108