class Date { private: long dayNumber; // 1 = Jan 1, 1900 and so on // constructs a date containing the specified day number. // throws an invalid_argument exception is the day number supplied // is invalid. Date (long dayNumber); public: // ** General Note ** // This class ensures that dates are always valid and always lie between // Jan 1, 1900 and Dec 31, 2099. // Invalid constructor arguments, read errors, and so on result in a // date of Jan 1, 1900. // constructs a date containing Jan 1, 1900 Date (); // constructs a date containing the specified date. // throws an invalid_argument exception if the date is invalid. Date (int day, int month, int year); // reads a date (in dd mm yyyy format) from the specfied input stream. // if an error of any sort (bad read, invalid date) occurs, the input // stream is left in the failed state. void read (istream &is); // writes a date to the specified output stream (in dd/mm/yyyy format) void write (ostream &os) const; // moves a date the specified number of days forward (positive day // values) or backwards (negative day values). throws an invalid_argument // exception (and leaves the object unchanged) if an attempt is made to // move a date outside of the permitted range. void move (int days); // returns the day of the week (1 = Monday, etc.) int dayInWeek () const; // returns a date in dd, mm, yyyy form void getDDMMYYYY (int &day, int &month, int &year) const; // returns the difference between two dates. this will be positive // if the other date is earlier than the date to which the method is // applied (and negative if the other date is earlier) int daysAfter (const Date &otherDate) const; // returns 1 if the date is greater than (later than) the other date. // returns -1 if the date is less than (earlier than) the other date. // returns 0 if the two dates are equal int compareTo (const Date &otherDate) const; // returns the date after a given date. // throws an invalid_argument exception if the next day is out // of the permitted range. Date nextDay () const; // returns the date "days" days beyond the date being opereated on. // "days" may be positive or negative. // throws an invalid argument exception if the result is out of the // permitted range. Date plusDays (int days) const; // returns true if the two dates are equal bool equals (const Date &otherDate) const; // logically identical to "equals" bool operator== (const Date &otherDate) const; };