#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. date& operator+=(int n) {day += n; return *this;} //const date operator+(int i) {date copy {*this}; copy.day += n; return copy;} //const date operator+(int i) {date copy {*this}; return copy += i;} //date& operator++() {++day; return *this;} //prefix increment //date& operator++() {return *this += 1;} //prefix increment //const date operator++(int) { //postfix increment // const date old {*this}; // ++day; // return old; //} //const date operator++(int) { //postfix increment // const date old {*this}; // ++*this; //(*this).operator++(); this->operator++(); // return old; //} friend ostream& operator<<(ostream& ost, const date& d); }; inline const date operator+(date d, int i) {return d += i;} inline const date operator+(int i, date d) {return d += i;} inline date& operator++(date& d) {return d += 1;} //prefix increment inline const date operator++(date& d, int) //postfix increment { const date old {d}; ++d; //d.operator++(); return old; } #endif