//Demonstrate the function equal. In this version equal is a friend of the class DayOfYear. #include class DayOfYear { public: friend int equal(DayOfYear date1, DayOfYear date2); //Precondition: date1 and date2 have values. //Returns true if date1 and date2 represent the same date; otherwise returns false. DayOfYear(int the_month, int the_day); //Precondition: the_month and the_day form a possible date. //Initializes the date according to the arguments. DayOfYear( ); //Initializes the date to January first. void input( ); void output( ); int get_month( ); //Returns the month, 1 for January, 2 for February, etc. int get_day( ); //Returns the day of the month. private: int month; int day; }; int main( ) { DayOfYear today, bach_birthday(3, 21); cout << "Enter today's date:\n"; today.input( ); cout << "Today's date is "; today.output( ); cout << "J. S. Bach's birthday is "; bach_birthday.output( ); if ( equal(today, bach_birthday)) cout << "Happy Birthday Johann Sebastian!\n"; else cout << "Happy Unbirthday Johann Sebastian!\n"; return 0; } int equal(DayOfYear date1, DayOfYear date2) { return ( date1.month == date2.month && date1.day == date2.day ); } DayOfYear::DayOfYear(int the_month, int the_day) { month = the_month; day = the_day; } DayOfYear::DayOfYear( ) { month = 1; day = 1; } int DayOfYear::get_month( ) { return month; } int DayOfYear::get_day( ) { return day; } //Uses iostream.h: void DayOfYear::input( ) { cout << "Enter the month as a number: "; cin >> month; cout << "Enter the day of the month: "; cin >> day; } //Uses iostream.h: void DayOfYear::output( ) { cout << "month = " << month << ", day = " << day << endl; }