Other Conversions

The void type

By definition, the void type has no value. Therefore, it cannot be converted to any other type, and no other value can be converted to void by assignment. However, a value can be explicitly cast to void.

Structure or union types

No conversions between structure or union types are allowed, except for the following. In C, an assignment conversion between compatible structure or union types is allowed if the right operand is of a type compatible with that of the left operand.

Table 3. Legal assignment conversions in C for structure or union types

Left operand type Permitted right operand types
C a structure or union type
a compatible structure or union type

Class types

C++There are no standard conversions between class types, but you can write your own conversion operators for class types.

Enumeration types

C In C, when you define a value using the enum type specifier, the value is treated as an int. Conversions to and from an enum value proceed as for the int type.

You can convert from an enum to any integral type but not from an integral type to an enum.

Related References

IBM Copyright 2003