#ifndef DATE_H #define DATE_H #include using namespace std; /* This is the header file for class date. Jan 1, 0 AD is day 0 Jan 2, 0 AD is day 1 Dec 31, 0 AD is day 364 Jan 1, 1 AD is day 365 etc. so day / 365 is the year and day % 365 is the day of the year (in the range 0 to 364 inclusive) */ class date { int day; static const int length[]; public: date(int m, int d, int y); date(); //Put today's date into the newborn object. date& operator+=(int n) {day += n; return *this;} date& operator-=(int n) {day -= n; return *this;} friend bool operator==(const date& d1, const date& d2) {return d1.day == d2.day;} friend bool operator<(const date& d1, const date& d2) {return d1.day < d2.day;} friend int operator-(const date& d1, const date& d2) {return d1.day - d2.day;} friend ostream& operator<<(ostream& ost, const date& d); friend istream& operator>>(istream& ist, date& d); }; inline date& operator++(date& d) {return d += 1;} inline date& operator--(date& d) {return d -= 1;} inline const date operator+(date d, int n) {return d += n;} //JF of Pr inline const date operator+(int n, date d) {return d += n;} inline const date operator-(date d, int n) {return d -= n;} inline const date operator++(date& d, int) { const date old {d}; //Call the copy constructor. ++d; return old; } inline const date operator--(date& d, int) { const date old {d}; --d; return old; } inline bool operator> (const date& d1, const date& d2) {return d2 < d1;} inline bool operator<=(const date& d1, const date& d2) {return !(d1 > d2);} inline bool operator>=(const date& d1, const date& d2) {return d2 <= d1;} inline bool operator!=(const date& d1, const date& d2) {return !(d1 == d2);} #endif