大家帮我看一个指针数组调用函数的问题吧
程序代码:
#include <iostream> using namespace std; double add (double x,double y) { return x+y; } double subtraction (double x,double y) { return x-y; } double calculate ( double x,double y,double (*p[3])(double,double))//这样定义有错吗? { double *p[0](double,double)=add;//这里报错 double *p[1](double,double)=subtraction; return (*p)(x,y); } int main () { double add (double x,double y); double subtraction (double x,double y); double calculate ( double x,double y,double (*p[2])(double,double)); double a,b; cout<<"Please input figure:"; while (cin>>a>>b) { for (int i=0;i<2;i++) { cout<<calculate (a,b,p[i])<<endl; } cout<<"Please input figure:"; } system("pause"); return 0; }