且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将参数从'double(double)'转换为'double(__ cdecl *)(double)'错误

更新时间:2023-02-04 09:22:59

我忘了

//双重整合:: f1(双x)
I forgot
// double Integration::f1(double x)


什么是f1?你的问题是正确的,但是你提供的代码太多了,不知道问题出在哪里。

What is f1? Your question is correct, but code you have provide is too
bad to understand where is a problem.


>
" Sydex" < SY **** @ comtv.ru> skrev i en meddelelse

新闻:cv ********** @ news.comcor-tv.ru ...

"Sydex" <sy****@comtv.ru> skrev i en meddelelse
news:cv**********@news.comcor-tv.ru...
当我编译代码时,我得到了错误
C2664:''Integration :: qgaus'':无法将参数1从''double
(double)''转换为''double(__ cdecl *)(double)''


errormessage表示你应该将指针传递给一个函数,但

传递了函数本身。

这一部分:
double Integration :: quad2d(double(* func)(double,double))

nfunc = func;

返回qgaus(f1,x1, x2); //错误有


尝试

返回qgaus(& f1,x1,x2);

代替。


作为替代方案,您可以通过引用传递该功能。


/ Peter
}
> // double(* nfunc)(double,double);

// qgaus(double(* f)(double),double min,double max)const;

请帮助
When I compile code I get error
C2664: ''Integration::qgaus'' : cannot convert parameter 1 from ''double
(double)'' to ''double (__cdecl *)(double)''
The errormessage indicates that you should pass a pointer to a function, but
passed the function itself.
in this part :
double Integration::quad2d(double (*func)(double,double))
{

nfunc = func ;

return qgaus(f1,x1,x2);//error there
Try
return qgaus(&f1,x1,x2);
instead.

As an alternative, you might pass the function by reference.

/Peter
}

//double (*nfunc)(double,double);

//double qgaus(double (*f)(double),double min,double max) const;

Please help