#ifndef DATE_H #define DATE_H /* 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) */ #include 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. //operator overloading (Feb 12) date& operator+=(int n) {day += n; return *this;} date& operator-=(int n) {day -= n; return *this;} explicit operator int() const {return day;} friend std::ostream& operator<<(std::ostream& os, const date& d); friend std::istream& operator>>(std::istream& is, date& d); friend int operator-(const date& a, const date& b); friend bool operator==(const date& a, const date& b); friend bool operator<(const date& a, const date& b); }; inline const date operator+(date d, int n) { d += n; return d; } inline const date operator+(int n, date d) { d += n; return d; } inline const date operator-(date d, int n) { d -= n; return d; } inline date& operator++(date& d) //prefix { return (d += 1); } inline const date operator++(date& d, int) //postfix { const date old {d}; ++d; return old; } inline date& operator--(date& d) //prefix { return (d -= 1); } inline const date operator--(date& d, int) //postfix { const date old {d}; --d; return old; } inline bool operator!=(const date& a, const date& b) { return !(a == b); } inline bool operator<=(const date& a, const date& b) { return (a < b) || (a == b); } inline bool operator>(const date& a, const date& b) { return b < a; } inline bool operator>=(const date& a, const date& b) { return !(a < b); } #endif