1.声明函数指针
说明:第一个参数为函数指针
type (* func)(type , type);
说明:type为任意类型的数据,如int ,float等,此表达式表明声明了返回值为type类型,有两个type类型的数据的参数
2.函数指针作为参数
type func(type (*p)(type ,type),type ,type);
说明:第一个参数为函数指针
3.函数指针的用法
void GetA(int a,double b);//这个是函数声明
void (*func)(int ,double);//声明函数指针
func=GetA;
func(3,4.0f);
4.其他声明函数指针的方法
typedef type (*func)(type ,type);//声明函数指针类型
func p;//定义func类型的函数指针p
说明:如果要声明参数为函数指针的函数,则函数指针的那部分参数不用写那么多代码,只需要写func即可代表那一串函数指针,如:
typedef int (*func)(int ,int);
//声明函数void getA(int (*func)(int ,int),double ,double);
void getA(func ,double , double);