Re: new to vc++

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Linux 2.6.32.19
    ... +static inline int s390_nohz_delay ... unsigned long prev; ... struct irq_desc *desc; ... return ret; ...
    (Linux-Kernel)
  • [ncurses] cat xxx |more
    ... int main ... int ch, prev, row, col; ... Works something like a linux cat. ... But this program is limited by *term window size. ...
    (comp.unix.programmer)
  • Re: 16x16Matrix
    ... assume int, but you can pick any other type (including the ones you ... then other replies in the thread might. ... Vladimir ... Prev by Date: ...
    (comp.lang.c)
  • Re: A question about reference in Python.
    ... This is really really really pointless code and a really really pointless ... Python is a superior dynamic programming ... self.prev = prev ... int *next; ...
    (comp.lang.python)
  • Re: A question about reference in Python.
    ... This is really really really pointless code and a really really pointless ... Python is a superior dynamic programming ... self.prev = prev ... int *next; ...
    (comp.lang.python)