Feb 10, 2013 at 4:47am
Hi Guys,
Can you please help me with issue. I would like to know what does ? symbol in lines (78 and 80)
And Please if you can write an alternative if statementThat would be appreciate it.
1 2 3 4 5 6
|
void Time::printStandard()
77 {
78 cout << ( ( getHour() == 0 || getHour() == 12 ) ? 12 : getHour() % 12 )
79 << ":" << setfill( '0' ) << setw( 2 ) << getMinute()
80 << ":" << setw( 2 ) << getSecond() << ( hour < 12 ? " AM" : " PM" );
81 } // end function printStandard
|
Last edited on Feb 10, 2013 at 4:56am
Feb 10, 2013 at 6:25am
It is the short version of if-then-else.
Before the ? is the if condition, before the : is done if the condition is true, after the : is done when the condition is false.
HTH
Feb 12, 2013 at 8:07am
Thank you TheIdeasMan
I got your point.