Aggregation





class DayOfYear { public: DayOfYear ( int initialMonth = 1, int initialDay = 1 ); void Set( int newMonth, int newDay ); void Set( int newMonth ); int GetMonthNumber( ) const; int GetDay( ) const; bool IsValid ( ) const; void Input( ); void Output( ) const; private: int m_month; int m_day; int m_isValid; };



class Vacation { public: Vacation(int startMonth, int startDay, int duration); void Set(int newMonth, int newDay); void Set(int newDuration); const DayOfYear& GetDayOfYear( ) const; int GetMonth( ) const; int GetDay( ) const; int GetDuration ( ) const; bool IsValid ( ) const; void Input ( ); void Output ( ) const; private: DayOfYear m_startDOY; int m_nrDays; bool m_isValid; };



Vacation Methods





const methods in Vacation





Designing for Code Reuse