This functions as intended since when you call
t.setHour( 18 )
A Time&, a reference to a Time object, is the return value.
What's more, it's described as
Time &Time::setHour( int h )
{
hour = ( h >= 0 && h < 24 ) ? h : 0;
return *this; // <--- right here
}
This is a pointer to the object on which the call was made within a member function, and *this is a reference to the object on which the call was made (the receiver object).
To put it another way, when you call setHour, the function adds the hour to the time and then returns a reference to the Time object on which you called.
As a result, when you use t.setHour(18), you'll also set the hour and get a reference to the receiver object.
You could then write.
t.setHour( 18 ).setMinute( 30 ).setSecond( 22 );
because it's interpreted as
((t.setHour( 18 )).setMinute( 30 )).setSecond( 22 );
and in each case the function returns a reference to t.
More broadly, every action you perform on the function's return value is identical to operations you would conduct on the object itself whenever a function returns a reference and that reference is *this.
Hope this is useful!