#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[12+1]; public: date(int m, int d, int y); date(); //Put today's date into the newborn object. // void print() const; // friend ostream& operator<<(ostream& ost, const date& d); date& operator+=(int n) {day += n; return *this;} date& operator-=(int n) {day -= n; return *this;} }; inline const date operator+(date d,int n) {return d += n;} inline const date operator+(int n, date d) {return d += n;} inline const date operator-(date d,int n) {return d -= n;} inline date& operator--(date& d) {return d -= 1;} inline date& operator++(date& d) {return d += 1;} inline const date operator++(date& d, int) { const date old {d}; ++d; return old; } inline const date operator--(date& d, int) { const date old {d}; --d; return old; } #endif