The first implementation will only return true if x.secs == y.secs
. The results of the first two comparisons will be discarded. The ,
operator evaluates to the value of its second operand, which in this case boils down to just x.secs == y.secs
.
The second one, however, is correct. If it is not working, then you must be setting the values of hrs
, mins
, and secs
incorrectly in the constructor of Duration
.
The problem that you have with getHours
is that you need to call it. It is a member function after all. So do x.getHours()
instead of x.getHours
.