// Fig. 8.6: date.h // Definition of class Date #ifndef DATE_H #define DATE_H #include using namespace std; class Date { // costretti a definire operatore << tramite funzione friend // per mancanza di metodi di lettura ... friend ostream & operator<<( ostream &, const Date & ); public: Date( int m = 1, int d = 1, int y = 1900 ); // constructor void setDate( int, int, int ); // set the date Date & operator++(); // preincrement operator Date operator++( int ); // postincrement operator const Date & operator+=( int ); // add days, modify object bool leapYear( int ) const; // is this a leap year? bool endOfMonth( int ) const; // is this end of month? private: int month; int day; int year; void helpIncrement(); // utility function static const int days[]; // array of days per month, // class attribute }; #endif