Compartir a través de


Cast Operators

A type cast provides a method for explicit conversion of the type of an object in a specific situation.   

Syntax

  • cast-expression:
    unary-expression

    ( type-name ) cast-expression

The compiler treats cast-expression as type type-name after a type cast has been made. Casts can be used to convert objects of any scalar type to or from any other scalar type. Explicit type casts are constrained by the same rules that determine the effects of implicit conversions, discussed in Assignment Conversions. Additional restraints on casts may result from the actual sizes or representation of specific types. See Storage of Basic Types for information on actual sizes of integral types. For more information on type casts, see Type-Cast Conversions.

See Also

Concepts

Cast Operator: ()