无法将参数从'double(double)'转换为'double(__ cdecl *)(double)'错误 [英] cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error

查看:753
本文介绍了无法将参数从'double(double)'转换为'double(__ cdecl *)(double)'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译代码时,我收到错误

C2664:''Integration :: qgaus'':无法转换参数1来自''double

(double)''这个部分的''double(__ cdecl *)(double)''



double Integration :: quad2d(double(* func)(double,double))

{


nfunc = func;


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


}


//双倍(* nfunc)(双倍,双倍);


// 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)''
in this part :
double Integration::quad2d(double (*func)(double,double))
{

nfunc = func ;

return qgaus(f1,x1,x2);//error there

}

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

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

Please help

推荐答案

我忘了

//双重整合:: 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



这篇关于无法将参数从'double(double)'转换为'double(__ cdecl *)(double)'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆