links:
http://en.cppreference.com/w/cpp/language/implicit_cast
http://stackoverflow.com/questions/5318424/implicit-conversion-between-datatypes
http://stackoverflow.com/questions/103512/in-c-why-use-static-castintx-instead-of-intx
http://stackoverflow.com/questions/5563000/implicit-type-conversion-rules-in-c-operators
http://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/
http://stackoverflow.com/questions/18133648/cast-unsigned-long-to-int-in-vc
http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast

summary:
const_cast
const_cast(expression) The const_cast() is used to add/remove const(ness) (or volatile-ness) of a variable.

static_cast
static_cast(expression) The static_cast() is used to cast between the integer types. ‘e.g.’ char->long, int->short etc.
Static cast is also used to cast pointers to related types, for example casting void* to the appropriate type.

dynamic_cast
Dynamic cast is used to convert pointers and references at run-time, generally for the purpose of casting a pointer or reference up or down an inheritance chain (inheritance hierarchy).

reinterpret_cast
Reinterpret cast simply casts one type bitwise to another. Any pointer or integral type can be casted to any other with reinterpret cast, easily allowing for misuse. For instance, with reinterpret cast one might, unsafely, cast an integer pointer to a string pointer.

Advertisements