Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>? : conditional operator (ternary)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ? :                     Conditional Operator (ternary)

 exp ? e1 : e2           Ternary conditional operator
 exp                     any scalar expression (int, char, enum, etc.)
 e1, e2                  any integral, floating type, or arithmetic
                         structure, union, or pointer expression

    The ? : operator evaluates either expression e1 or e2, depending upon
    the truth of e1.  If exp yields a non-zero value (TRUE), e1 is
    evaluated and that is the value returned; otherwise, e2 is evaluated,
    and that is the value returned.

           k = (i > j) ? i : j;   /* This is equivalent to:  k = max(i,j) */

    This operator cannot be overloaded in C++.



Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson