#include #include "date.h" const int date::length[] = { 0, //dummy 31, //january 29, //february 31, //march 30, //april 31, //may 30, //june 31, //july 31, //august 30, //september 31, //october 30, //november 31 //december }; date::date(int initial_month, int initial_day, int initial_year) throw (bad_month) { year = initial_year; if (initial_month < january || initial_month > december) { throw bad_month(initial_month); } month = initial_month; if (initial_day < 1 || initial_day > length[month]) { throw bad_month_and_day(month, initial_day); } day = initial_day; } date& date::operator++() throw (overflow) //prefix { if (++day > length[month]) { day = 1; if (++month > december) { month = january; if (year >= INT_MAX) { //Undo the ++'s in lines 37 and 39. month = december; day = length[month]; throw overflow(); } ++year; } } return *this; } date& date::operator--() throw (underflow) //prefix { if (--day < 1) { if (--month < january) { month = december; if (year <= INT_MIN) { //Undo the --'s in lines 56 and 57. month = january; day = 1; throw underflow(); } --year; } day = length[month]; } return *this; }