I was wondering what the "?" and ":" do when in code like this
what does the "?" and ":" do in the previous code. I know its probably somewhere, but I am having trouble finding the answer.Code:
12 ? 3 : 20
Thanks in advance.
Printable View
I was wondering what the "?" and ":" do when in code like this
what does the "?" and ":" do in the previous code. I know its probably somewhere, but I am having trouble finding the answer.Code:
12 ? 3 : 20
Thanks in advance.
It will be true the result (Different of 0) cuz 12 is a number different of zero.
Code:(condition) ? (do this if true) : (do this if false);
thanks, I could of sworn it had something to do with TRUE or FALSE.
A more accurate definition of what it does would probably be the whole expression becomes instead of do this
e.g.
Code:int x;
bool y=true;
x=y?3+3:cout<<"This won't execute";
Of course it won't execute. That's C++ and this is a C board...Quote:
Originally posted by Panopticon
e.g.
Code:int x;
bool y=true;
x=y?3+3:cout<<"This won't execute";
Quzah.
LoL! damn.. Habitual error :p