Default
Google

Operators: ? Operator

Applies To: C++Builder 1 or higher
Category: C++ Language

The ? operator is similar to the if … else keywords. It takes this general form:
 
expression_1 ? expression_2 : expression_3;
 
If expression_1 is true, then the value of expression_2 is returned. If expression_1 is false, then the outcome of the operation is expression_3. For example:
 
y = (x < 5) ? 35 : 50
 
If x < 5, then the value of y is set to 35. If x >= 5, then y = 50.
Using ? has many advantages. First, it saves you time and second, the compiler produces code faster than for the if … else keywords.

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange