static_cast [C++ Reference]
Keywords: keywords,static_cast
Date: 2009-09-05T13:03:47-0700

[[static_cast]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## static_cast

Syntax:

        TYPE static_cast<TYPE> (object);

The static_cast keyword can be used for any normal conversion between types. This includes any casts between numeric types, casts of pointers and references up the hierarchy, conversions with unary constructor, conversions with conversion operator. For conversions between numeric types no runtime checks if data fits the new type is performed. Conversion with unary constructor would be performed even if it is declared as explicit

It can also cast pointers or references down and across the hierarchy as long as such conversion is available and unambiguous. No runtime checks are performed.

Related Topics: const_cast, dynamic_cast, reinterpret_cast, A comparison of the C++ casting operators

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •