| RegalleonZ (2) | |
|
Hi, I'm new to C++ and in my assignment I have these two lines: (day<=29) ? valid=true : valid=false; (day<=28) ? valid=true : valid=false; It is for verifying the days in February. I've never seen ? and : used like this so I would like some clarification. Is this saying that if the day<=29/28 then set valid to true, otherwise false? Would I be correct in assuming that? | |
|
|
|
| Disch (8338) | |||||
Yes, you are correct. That's exactly how the ternary operator works:
| |||||
|
|
|||||
| RegalleonZ (2) | |
| Oh I see. Its just written that way in my assignment and I've never seen it before nor was it explained in anything I have read so far. Thanks for the clarification! =D | |
|
|
|