How is this working

how is this working without any if/else statement
1
2
3
4
 void Time::setSecond( int s )
  {
     second = ( s >= 0 && s < 60 ) ? s : 0; // validate second
  } // end function setSecond 
The ?: operator is a conditional one. It is ternary, and reads as...


(if CONDITION) ? (expression) : (alternative expression)


If the condition is true, the first expression is executed, otherwise, the alternative expression is.
Topic archived. No new replies allowed.