Trying to get my leapyear checker to work, but I'm finding it's not working regardless how I move things about. Any tips?
In member function `void DayOfYear::check_date()':
99 invalid use of member (did you forget the `&' ?)
99 At global scope:
216 prototype for `int DayOfYear::checkleapyr(int)' does not match any in class `DayOfYear'
23 int DayOfYear::checkleapyr()
#include <iostream>
using namespace std;
class DayOfYear
{
public:
void input( );
void output( );
void set(int new_month,int new_day,int new_year);
//Precondition: new_month and new_day form a possible date.
//Postcondition: The date is reset according to the arguments.
int get_month( );
//Returns the month, 1 for January, 2 for February, etc.
int get_day( );
//Returns the day of the month.
int get_year( );
//Return the year int checkleapyr( );
private:
void check_date( );
int month;
int day;
int year;
};
int main( )
{
DayOfYear today, bach_birthday;
cout << "Enter today's date:\n";
today.input( );
cout << "Today's date is ";
today.output( );
bach_birthday.set(3, 21, 1685);
cout << "J. S. Bach's birthday is ";
bach_birthday.output( );
if (today.get_month( ) == bach_birthday.get_month( ) && today.get_day( ) == bach_birthday.get_day( ))
cout << "Happy Birthday Johann Sebastian!\n";
else
cout << "Happy Unbirthday Johann Sebastian!\n";
system("pause");
return 0;
}
//Uses iostream:
void DayOfYear::input( )
{
cout << "Enter the month as a number: ";
cin >> month;
cout << "Enter the day of the month: ";
cin >> day;
cout << "Enter the year: ";
cin >> year;
checkleapyr( );
check_date( );
}
//Uses private member functions to accept the month and day of the month.
Sorry im on my phone so hard to type what I want. In short, your checkleapyr always returns 0. If you intend to return then just return where you are setting the variable that you passed in. also, since you pass by value, assigning checkleapyr inside the function is not reflected ouit also looks like your call to the function checkleapyr is incorrect, look at your call site.