class Time
1: // Filename: TIME3.H
2: // Purpose: Specification file corresponding to TIME3.CPP. This version
3: // adds three accessor functions and a friend function.
5: #ifndef TIME3_H
6: #define TIME3_H
8: class Time
9: {
10: // The following function is a "friend" function of the Time
11: // class and has direct access to its private data members.
12: friend bool EqualTo3(const Time& t1, const Time& t2);
13: // Pre: t1 and t2 have been initialized.
14: // Post: Returns true if t1 and t2 are the same time
15: // and false otherwise.
17: public:
19: // The following five "interface functions" are exactly the
20: // same as those in TIME2.H. For brevity we have omitted the
21: // comments and pre/post-conditions, which are also the same.
22: Time();
23: Time(int hoursInitial, int minutesInitial, int secondsInitial);
24: void Set(int hoursNew, int minutesNew, int secondsNew);
25: void Increment();
26: void Display() const;
29: // The following functions are called "accessor functions"
30: // and allow a client/user to get the value of the data members.
31: // But note that the client/user still has no direct access
32: // to the data members, only the access provided.
34: int Hours() const;
35: // Pre: none
36: // Post: Value of data member "hours" is returned.
38: int Minutes() const;
39: // Pre: none
40: // Post: Value of data member "minutes" is returned.
42: int Seconds() const;
43: // Pre: none
44: // Post: Value of data member "seconds" is returned.
47: // The following function is another member function.
48: bool EqualTo1(const Time& otherTime) const;
49: // Pre: self and otherTime have been initialized.
50: // Post: Returns true if self and otherTime are the same time
51: // and false otherwise.
54: private:
55: int hours;
56: int minutes;
57: int seconds;
58: };
60: #endif