#ifndef DATE_H #define DATE_H #include //for class ostream (the class of the object cout) 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. //int operator-(const date& another) {return day - another.day;} //memb func friend int 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 bool operator< (const date& d1, const date& d2) {return d1.day < d2.day;} friend ostream& operator<<(ostream& ost, const date& d); }; inline bool operator!=(const date& d1, const date& d2) {return !(d1 == d2);} inline bool operator<=(const date& d1, const date& d2) {return d1 < d2 || d1 == d2;} inline bool operator>=(const date& d1, const date& d2) {return !(d1 < d2);} inline bool operator> (const date& d1, const date& d2) {return !(d1 <= d2);} #endif