RE: C++ question: where does int() come from ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

>Is the int('A') a function call provided by C++ library or the compiler will do the conversion during compilation time ?

I might be getting the terminology wrong, but here goes anyway...

The int('A') is a constructor cast.  For me, I prefer it to the C style cast, ala (int)'A'.  Especially in the kind of situation in your example.

I'm not sure what the general consensus is amongst the C++ developer community regarding constructor casts, but I do know that there is a general disdain of C style casts.  The recommendation by the C++ gurus is to prefer static_cast, const_cast, dynamic_cast, and reinterpret_cast ... and I presume that constructor casts would be right up there as well.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux