lsfzsfz 2014-07-03 03:01 采纳率: 0%
浏览 1919

这段程序代码怎么改??????

#include "iostream"
using namespace std;
class Gelr
{
public:
void gelr1(double t,double y[] ,int n,double h,int k,double z[][11]);
void gelrf(double t,double y[],int n,double d[]);
//void display();
protected:
double t;
double y[3];
int n;
double h;
int k;

double z[3][11];
double d[3];
};
void Gelr::gelr1(double t,double y[],int n,double h,int k, double x[])
{
int i,j;
double x,*d;
d=static_cast(malloc(n*sizeof(double)));
for (i=0; i<=n-1; i++) z[i*k]=y[i];
for (j=1; j<=k-1; j++)
{ x=t+(j-1)*h;
gelrf(x,y,n,d);
for (i=0; i<=n-1; i++)
y[i]=z[i*k+j-1]+h*d[i];
x=t+j*h;
gelrf(x,y,n,d);
for (i=0; i<=n-1; i++)
d[i]=z[i*k+j-1]+h*d[i];
for (i=0; i<=n-1; i++)
{ y[i]=(y[i]+d[i])/2.0;
z[i*k+j]=y[i];
}
}
free(d); return;
}
void Gelr::gelrf(double t,double y[],int n,double d[])
{
t=t;
n=n;
d[0]=y[1];
d[1]=-y[0];
d[2]=-y[2];
return;
}
int main()
{
int i,j;
double y[3],z[3][11],t,h,x;
y[0]=-1.0; y[1]=0.0; y[2]=1.0;
t=0.0; h=0.01;
Gelr g;
g.gelr1(t,y,3,h,11,z);
cout<<"\n"<<endl;
for (i=0; i<=10; i++)
{ x=i*h;
cout<<"t:"<<x<<endl;
for (j=0; j<=2; j++)
cout<<"y("<<j<<")=%"<<z[j][i]<<endl;
cout<<"\n"<<endl;
}
cout<<"\n"<<endl;
return 0;
}

--------------------Configuration: sdt - Win32 Debug--------------------
Compiling...
sdt.cpp
D:\防灾\C++程序设计电子教案\微分方程\std\sdt.cpp(19) : error C2511: 'gelr1' : overloaded member function 'void (double,double [],int,double,int,double [])' not found in 'Gelr'
D:\防灾\C++程序设计电子教案\微分方程\std\sdt.cpp(4) : see declaration of 'Gelr'
执行 cl.exe 时出错.

sdt.exe - 1 error(s), 0 warning(s)

  • 写回答

2条回答

  • Blank_CN 2014-07-03 03:19
    关注

    第一个错误是说你的“gelr”这个函数参数超过了声明时给的参数个数,你查看下这个函数的声明,看它有几个参数和各自的类型。

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?