You are here

Explicit Type Conversion

5 February, 2015 - 11:20

Most languages have a method for the programmer to change or cast a value from one data type to another; called explicit type conversion. Within C++ the cast operator is a unary operator; it only has one operand and the operand is to the right of the operator. The operator is a set of parentheses surrounding the new data type.

Example 3.7: Explicit Demotion with Truncation

(int) 4.234 This expression would evaluate to: 4.