#ifndef DATEH #define DATEH #include using namespace std; class date; class timebomb { int sum; bool ticking; //true if this timebomb is still ticking timebomb(int initial_sum): sum(initial_sum), ticking(true) {} public: ~timebomb() { if (ticking) { cerr << "forgot to divide the sum of two dates by 2\n"; } } const date operator/(int n); friend timebomb operator+(const date& d1, const date& d2); }; class date { static const int length[]; static const int pre[]; int day; date(int initial_day): day(initial_day) {} public: enum month_type { january = 1, february, march, april, may, june, july, august, september, october, november, december }; date(int month, int day, int year); void print() const; friend timebomb operator+(const date& d1, const date& d2); friend const date timebomb::operator/(int n); }; inline timebomb operator+(const date& d1, const date& d2) { return d1.day + d2.day; } inline date midpoint(const date& d1, const date& d2) { return (d1 + d2) / 2; //return operator+(d1, d2).operator/(2); } #endif