//Program to demonstrate the function equal. The class DayOfYear
//is the same as in self-Test Exercise 23-24 in Chapter 10.
DayOfYear(int the_month, int the_day);
//Precondition:the_month and the_day form a
//possible date. Initializes the date according to the arguments
//Initializes the date to January first.
//Returns the month, 1 for January, 2 for February, etc.
//Returns the day of the month;
bool 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 today, bach_birthday(3, 21);
cout << "Enter today's date:\n";
cout << "Today's date is: ";
cout << "J. S. Bach's birthday is ";
if ( equal(today, bach_birthday))
cout << "Happy Birthday Johann Sebastian\n";
cout << "HappyUnbirthday Johann Sebastian\n";
bool equal(DayOfYear date1, DayOfYear date2)
return (date1.get_month() == date2.get_month() &&
date1.get_day() == date2.get_day() );
DayOfYear::DayOfYear(int the_month, int the_day)
: month(the_month), day(the_day)
cout << "Enter the month as a number: ";
cin >> month;
cout << "Enter the day of the month: ";
cin >> day;
cout << "month = " << month
<< ", day = " << day << endl;
Hehe, it seems I know why. You have defined "check_date()" in the head, but you didn't describe it below. That's why the program first complains about check_date() first and then about the other function although it is declared.
I wonder why the compiler doesn't complain that function is not defined completely, normally you should get a undefined symbol error...
Do you use an IDE? If so, you should be able to get it to automatically make a function stub for each function you declare. Usually there is a menu option to make a new class, this creates a separate header file and cpp file in the project. Once you type a new function declaration in the class, there should be some way of getting the system to make a function stub for it in the cpp file. That way you won't forget to define any of the functions.