Ternary conditional operator: Difference between revisions

Content deleted Content added
m Fix reference, remove unreferenced tag.
m Result type: correct presumed typo
Line 64:
===Result type===
Clearly the type of the result of the <code>?:</code> operator must be in some sense the [[type unification]] of the types of its second and third operands. In C this is accomplished for [[numeric type]]s by [[arithmetic promotion]]; since C does not have a [[type hierarchy]] for [[pointer]] types, pointer operands may only be used if they are of the same type (ignoring [[type qualifier]]s) or one is [[void]] or [[NULL]]. It is [[undefined behaviour]] to mix pointer and integral or incompatible pointer types; thus
<source lang="c">>number = spell_out_numbers ? "forty-two" : 42;</source>
will result in a [[compile-time error]] in most compilers.