C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-11-2001, 09:46 PM   #1
Unregistered
Guest
 
Posts: n/a
time class

Greetings,

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
  Reply With Quote
Old 12-11-2001, 10:12 PM   #2
Unregistered
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
};
  Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 12:12 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22