再次暧昧的召唤 [英] Ambiguous call again

查看:84
本文介绍了再次暧昧的召唤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对过载功能进行了模糊调用。再次出错。


这是函数:


int nGetProfWidth(int ncols,unsigned ProfSpec)

{

if((ProfSpec& PROF_2d)== 0)

返回ncols;

return int(sqrt(ncols)); //这里的错误是什么

}


当我想要一个整数返回时(如上面的代码 - 至少

我认为它应该返回一个整数),我应该如何重写这段代码?


Anna

解决方案

Anna Smidt写道:


我对重载函数进行了模糊调用再次出错。


这是函数:


int nGetProfWidth(int ncols,unsigned ProfSpec)

{

if((ProfSpec& PROF_2d)== 0)

返回ncols;

return int(sqrt(ncols)); //这里的错误是什么

}


当我想要一个整数返回时(如上面的代码 - 至少

我认为它应该返回一个整数),我应该如何重写这段代码?



Anna:


return int(sqrt(double(ncols)));


你知道大多数整数都没有精确的整数平方根吗?


-

David Wilkinson

Visual C ++ MVP


你知道大多数整数都没有精确的整数平方根吗?


谢谢和.. 。

不,我不知道。但是我首先已经错了

因为我想的是一个VB6整数,它不等于

VC ++整数据我所知。我已经厌倦了趴在

桌子上,所以我明天早上会查一下(是的,我有一本C ++书:-)


Anna


哦,我在睡觉前有一个问题:


double hypotenuse = sqrt(square(py) - qy)+ square(px - qx));


为什么在sqrt(" and before the last)之后有空格?

I am having an "ambiguous call to overloaded function" error again.

This is the function:

int nGetProfWidth (int ncols, unsigned ProfSpec)
{
if ((ProfSpec & PROF_2d) == 0)
return ncols;
return int(sqrt(ncols)); //HERE THE ERROR IS THROWN
}

When I want to have an integer returned (as in the code above - at least
I think it should return an integer), how should I rewrite this code?

Anna

解决方案

Anna Smidt wrote:

I am having an "ambiguous call to overloaded function" error again.

This is the function:

int nGetProfWidth (int ncols, unsigned ProfSpec)
{
if ((ProfSpec & PROF_2d) == 0)
return ncols;
return int(sqrt(ncols)); //HERE THE ERROR IS THROWN
}

When I want to have an integer returned (as in the code above - at least
I think it should return an integer), how should I rewrite this code?

Anna:

return int(sqrt(double(ncols)));

You do know that most integers do not have an exact integer square root?

--
David Wilkinson
Visual C++ MVP


You do know that most integers do not have an exact integer square root?

Thanks and...
No, I did not know that. But I was wrong in the first place already
anyway because I was thinking of a VB6 integer which isn''t equal to
VC++ integers as far as I know. I''m already tired enough to drop on the
table, so I will look it up tomorrow morning (yes, I have a C++ book :-)

Anna


Oh, I have a question before I go to bed:

double hypotenuse = sqrt( square(p.y - q.y) + square(p.x - q.x) );

Why is there a space after "sqrt(" and before the last ")"?


这篇关于再次暧昧的召唤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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