[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Conversions in the Conditional Operator

(ARM §5.16) The compiler does not apply reference conversions to the second and third expressions of the conditional operator. In other words, unless the second and third expressions are numeric types, they must be the same type.
A conversion in a conditional operator:
class base { };
class derived : public base { };
static void foo(derived i)
{
base &a = i;
derived &b = i, c;
c = (sizeof(0) ? a:b); // ERROR: b is not converted to (base &)
c = (sizeof(0) ? a:(base &)b) // OK, typecast
}
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 17, 2000