too many actual parameters?
从教科书(《C语言程序设计》(第二版)主编 丁亚涛,p174)上照抄的一个程序:#include <math.h>
#include<stdio.h>
float integeral(double(*funp)(),float a,float b)
{
float s,h,y;
int n,i;
s=((*funp)(a)+(*funp)(b))/2.0; /*[f(a)+f(b)]/2作为求和的初值*/
n=100;h=(b-a)/n;
for (i=1;i<n;i++)
s=s+(*funp)(a+i*h);
y=s*h;
return(y);
}
double f(double x)
{
return(sqrt(4.0-x*x));
}
main()
{
float s1,s2,s3;
s1=integeral(sin,0.0,3.1415926/2);
s2=integeral(cos,0.0,3.1415926/2);
s3=integeral(f,0.0,2.0);
printf("s1=%f,s2=%f,s3=%f\n",s1,s2,s3);
}
在VC6上编译时候提示“cpp(7) : error C2197: 'double (__cdecl *)(void)' : too many actual parameters”
“cpp(21) : error C2664: 'integeral' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(void)'
None of the functions with this name in scope match the target type”
怎么回事?怎么解决?谢谢