#ifndef DATE_H #define DATE_H /**************************************************************************** ** COPYRIGHT (C): 1997 Cay S. Horstmann. All Rights Reserved. ** PROJECT: Practical OO Development with C++ and Java ** FILE: date.h ** PURPOSE: date class for chapter 3 ** VERSION 1.0 ** PROGRAMMERS: Cay Horstmann (CSH) ** RELEASE DATE: 3-15-97 (CSH) ** UPDATE HISTORY: ****************************************************************************/ #line 17 "date.cpp" #include #line 20 "date.cpp" class Date { public: enum Weekday { MON, TUE, WED, THU, FRI, SAT, SUN }; Date(); Date(int d, int m, int y); void advance(long n); int day() const; int month() const; int year() const; Weekday weekday() const; Date add_days(long n) const; long days_between(const Date& b) const; int compare(const Date& b) const; static int compare(const Date* a, const Date* b); static Date today(); private: bool is_valid() const; static bool is_leap(int year); int _day; int _month; int _year; static int days_per_month[12]; }; #line 140 "date.cpp" extern istream& operator>>(istream& is, Date& date); #line 162 "date.cpp" extern ostream& operator<<(ostream& os, const Date& date); #line 251 "date.cpp" inline int Date::day() const { return _day; } #line 257 "date.cpp" inline int Date::month() const { return _month; } #line 263 "date.cpp" inline int Date::year() const { return _year; } #endif