Solved
HW Help on classes
Posted on 2002-03-08
Hi,
I am doing some hw on classes, and i am really stuck on a member function i am working on.
i need to subtract two time stamps, and return the difference.
void TimeStamp::diff( TimeStamp &ts2, int &weeks, int &days, int &hours, int &minutes ) {
// subtract 2 timestamps
// convert to weeks, days, hours, minutes...
// weeks = days / 7;
// days = day % 7;
// days += 365 * years;
// year day hour minute
// ---- --- ---- ------
// y1 d1 h1 m1
// - y2 d2 h2 m2
// ---------------------------
// [ ] [ ] [ ] [ ]
// look out for negative numbers, where as if m1 and m2 return neg, u need to compestate by adding then to the hour column
}
this is the def:
class TimeStamp {
private:
int year;
int month;
int day;
int hour;
int minute;
static const int daysInMonth[ 13 ];
public:
TimeStamp() {};
TimeStamp( int yr, int mo, int da, int ho, int mi );
void display();
bool operator >( TimeStamp &rhs );
void diff( TimeStamp &ts2, int &weeks, int &days, int &hours, int &minutes );
private:
int dayofyear();
};
what i cant figure out is, how do i get the data? the user puts in from standard input teh values of t1 and t2, and i need to find the difference, but the reading of those values (at least as of now) arent stored in private data....so i am really puzzled in what to do....
actually, very stuck, i just need a bit of help to start me off so i can go on my way....
i hope i gave enough info for some1 to help me a bit.
thanks!