Jan 22, 2012 at 10:11am UTC
Where the question mark "?" is used in c++ programs other than ternary operators.
Jan 22, 2012 at 10:35am UTC
I think I haven't seen it in other places.
There is also the escape char: \?
if it counts.
Jan 22, 2012 at 5:08pm UTC
its is trianary operator ..
as per the below example
if ( a > b ) ? return 1 : return 9;
Jan 22, 2012 at 5:39pm UTC
JLBorges,
Wow nice example, I just wanted to ask "Is that C++" ahahhaahh
Jan 22, 2012 at 8:12pm UTC
Strictly speaking, neither C or C++ handle trigraphs as a language element. They are handled by the preprocessor.
Trigraphs exist so that C (and C++) can be used on computers which use a charset which doesn't include certain characters. For example, EBCDIC doesn't always provide curly {s and }s.
Jan 22, 2012 at 11:48pm UTC
return cannot be used with the ternary operator.
Wazzak
Last edited on Jan 22, 2012 at 11:48pm UTC
Jan 22, 2012 at 11:57pm UTC
did you mean:
return a > b ? 1 : 9;
Jan 23, 2012 at 12:00am UTC
KBW, evidence? The ternary operator only accepts expressions. return is a statement which doesn't yield a value.
Wazzak
Last edited on Jan 23, 2012 at 12:02am UTC
Jan 23, 2012 at 12:15am UTC
Yes, that's valid, because the operator yields an expression which return accepts, not a statement.
Wazzak