... the class’s data members and other member functions—e.g., lines 28–29 and 36–38 can access data members
hour
,minute
andsecond
because they’re declared inTime.h
as data members of classTime
.
9.2.7 Time
Class Member Function setTime
and Throwing Exceptions
Function setTime
(lines 12–23) is a public
function that declares three int
parameters and uses them to set the time. Line 14 tests each argument to determine whether the value is in range, and, if so, lines 15–17 assign the values to the hour
, minute
and second
data members, respectively. The hour
value must be greater than or equal to 0
and less than 24
, because universal-time format represents hours as integers from 0 to 23 (e.g., 11 AM is hour 11, 1 PM is hour 13 and 11 PM is hour 23; ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.