Implicit Type Conversions

An expression e of a given type is implicitly converted if used in one of the following situations:

The compiler will allow an implicit conversion of an expression e to a type T if and only if the compiler would allow the following statement:

  T var = e;

For example when you add values having different data types, both values are first converted to the same type: when a short int value and an int value are added together, the short int value is converted to the int type.

You can perform explicit type conversions using one of the cast operators, the function style cast, or the C-style cast.

Related References

IBM Copyright 2003