Afficher un message
Vieux 30/06/2008, 16h47   #2
Jerry Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Implicit conversion from int to double

In article <da23fd45-4729-4a98-8a99-
b9ef4dd8800a@l28g2000prd.googlegroups.com>, amphetaman@gmail.com says...
> I know this might seem kind of silly, but is it necessary to cast int
> to double?
>
> Do I have to do
>
> int i = 42;
> double d = static_cast<double>(i);
>
> or can I just do d = i?


The language allows you to do the assignment without an explicit type
cast. Somewhere, I suppose there might be a compiler that warns you
about doing it, but that's a bit hard to guess -- someday I might create
a web site of "inane compiler warnings", but I haven't yet...

--
Later,
Jerry.

The universe is a figment of its own imagination.
  Réponse avec citation
 
Page generated in 0,04512 seconds with 9 queries