Re: new to vc++
- From: "Kizzy" <kizzy@xxxxxxxxxxxxx>
- Date: Mon, 24 Oct 2005 14:41:39 -0700
Yes, it does, but I was curious as to why it works ok in vc++ 6.0, and vc++
7.1 if compiled as a .c file, but fails if it is a .cpp file. By "ok" I
mean that the compiler apparently automatically converts the int to an
unambiguous float or double and the function call works. It is curious that
this changed in vc++ 7.1 cpp.
"Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx> wrote in message
news:eBpPRAN2FHA.2436@xxxxxxxxxxxxxxxxxxxxxxx
> Kizzy wrote:
>> Why does the following occur with cl.exe?
>>
>> #include <stdio.h>
>> #include <math.h>
>>
>> int main(void)
>> {
>> int nin;
>> double y;
>> nin=9;
>> y=sqrt(nin);
>> printf("The sqrt of %d is %f \n", nin,y);
>> return 0;
>> }
>>
>> gives correct answer when compiled with vc++ 6.0 as sqi.c or sqi.cpp
>> gives correct answer where compiled with vc++ 7.1 (2003) as sqi.c
>> gives C2668 "ambiguous call to overloaded function" when compiled with
>> vc++ 7.1 (2003) as sqi.cpp
>
> My copy of 7.1 actually lists all overloaded functions it could use.
> Doesn't yours do the same? Essentially, there is no 'sqrt(int)' and
> it has to convert the 'nin' into either 'float' or 'double' or 'long
> double', and it can't pick, they are all the same. You have to tell
> the compiler which version to choose:
>
> y=sqrt(double(nin));
>
> , for example.
>
> V
.
- Follow-Ups:
- Re: new to vc++
- From: Nikolaos D. Bougalis
- Re: new to vc++
- References:
- new to vc++
- From: Kizzy
- Re: new to vc++
- From: Victor Bazarov
- new to vc++
- Prev by Date: Re: HBRUSH creates errors
- Next by Date: Re: new to vc++
- Previous by thread: Re: new to vc++
- Next by thread: Re: new to vc++
- Index(es):
Relevant Pages
|