int (*p)(int x)是函数指针
可以直接使用,它的返回值是int型
int * fun()
{
int b = 90;
int *a = &b;
return a;
}
void main(){
cout << "b地址:"<<fun() << endl;
cout << "b的值:"<<*fun() << endl;
}
b的值:90
-------------------------------------------------------------------------------------
int f(int a, int b)
{
return a + b;
}
int g(int a, int b)
{
return a - b;
}
void main()
{
int(*p)(int a, int b);//定义指向函数的指针,参数表必须和要指向的函数一致
p = f;
cout << (*p)(200, 100) << endl;
p = g;
cout << (*p)(200, 100) << endl;
}