Thursday, July 9, 2009

In C++ what is the difference between the functions: double() and static_cast<double>()?

Im new to programming. Need to know this since i have to find the output of a program that uses both of em.

In C++ what is the difference between the functions: double() and static_cast%26lt;double%26gt;()?
using (double) is the old c-style casting. It works most of the time, but it's up to the programmer to make sure that the cast is safe given the actual types involved. static_cast%26lt; double %26gt;() is equivalent, semantically, but was added since it's easier to see when looking at code. Makes it easier for tools, such as IDE's to identify and support manipulations of these casts. Some compilers can also do some additional type safety checks with this kind of cast, and issue warnings about unsafe casts.


No comments:

Post a Comment