November 2002
Beginner to intermediate
142 pages
4h 19m
English
A type conversion yields the value of an expression in a new type. Conversion can be performed only on scalar types, i. e., arithmetic types and pointers.
A type conversion always conserves the original value, if the new
type is capable of representing it. Floating-point numbers may be
rounded on conversion from double to
float, for example.
Type conversions can be implicit —i. e., performed by the compiler automatically—or explicit , through the use of the cast operator. It is considered good programming style to use the cast operator whenever type conversions are necessary. This makes the type conversion explicit, and avoids compiler warnings.
Read now
Unlock full access