![]() |
| | #1 |
| Guest
Posts: n/a
| time class I am trying to modify the definition of this "Time" object so that time is represented internally as the number of seconds before or after noon. I want time before noon to be a negative number, time after noon will be positive and noon will be 0. Not for sure what to look at first. Ok the int hour is time 0 to 23, minute and sec o to 59. How do I define noon as 0, then go negative? The time as of now is initialized to 12am as 0. So how do I initialize the time so that 12pm is 0? Then to go in the neg direction? 12 am to 11:59am is negative and 12:01pm to 11:59 pm is positive. Thank you Terri #ifndef TIME6_H #define TIME6_H class Time { public: Time( int = 0, int = 0, int = 0 ); // set functions Time &setTime( int, int, int ); Time &setHour( int ); Time &setMinute( int ); Time &setSecond( int ); int getHour() const; int getMinute() const; int getSecond() const; void printMilitary() const; void printStandard() const; private: int hour; int minute; int second; }; #endif |
|
| | #2 |
| Guest
Posts: n/a
| Forgot to mention that I only need 1 data member. See If I could use 2 I would use something like this maybe: private; int sinceMidnight; // seconds since midnight int aftermidnight; // seconds after midnight }; |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help in time zone | Gong | C++ Programming | 2 | 01-03-2007 04:44 AM |
| Help with assignment! | RVDFan85 | C++ Programming | 12 | 12-03-2006 12:46 AM |
| help working with class files for first time | jrb47 | C++ Programming | 12 | 11-30-2006 09:20 AM |
| I apologize. Good bye. | doubleanti | A Brief History of Cprogramming.com | 14 | 05-03-2002 06:51 PM |
| Difficulty superclassing EDIT window class | cDir | Windows Programming | 7 | 02-21-2002 05:06 PM |