函数指针

1.指针声明方式

声明一个类型的函数指针:

int (*pf)(int)//括号中是函数的形参类型
int func(int a)
{cout<<"I am a function"<

声明一个函数指针很简单,只需要和平时声明函数的方式一样,把函数名换成(*pf)就表示一个函数指针。
2.利用typedef关键字

typedef const double *(*p_fun)(const double, int);
const double *func(const double, int);
p_fun p1 = func;//p_fun now is a type;

你可能感兴趣的:(函数指针)