#include<iostream.h>
#include<math.h>
int n;
double f(double x)
{
return 1/(1+x*x);
}
double AttoTrap(double(*f)(double),double a,double b)
{
int i;
double x,s,h=b-a;
double t1,t2=h/2.0*(f(a)+f(b));
int n=1;
do 
{
s=0.0;t1=t2;
for(i=0;i,n;i++)
{
x=a+i*h+h/2;
s+=f(x);
}
t2=(t1+s*h)/2.0;
n*=2;
h/=2;
}
while(fabs(t2-t1)>1e-6);
return t2;
}void main ()
{ double s;
double f(double);
double AutoTrap(double (*f)(double),double,double);
    s=AutoTrap(f,0.0,1.0);
cout<<"n="<<n<<"  "<<"x="<<s<<endl;
}
编译出现如下错误:
****.obj : error LNK2001: unresolved external symbol "double __cdecl AutoTrap(double (__cdecl*)(double),double,double)" (?AutoTrap@@YANP6ANN@ZNN@Z)
Debug/****.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.