I get this strange linker error when I compile my code...
/tmp/ccO8yU7S.o: In function `bad_date(int, Date::Month, int)':
main.cpp:(.text+0xf5): undefined reference to `leapyear(int)'
collect2: error: ld returned 1 exit status
bool bad_date(int y, Date::Month m, int d)
{
if (y<1582) returnfalse;
if (m>12) returnfalse;
if (d<=0) returnfalse; // d must be positive
int days_in_month = 31; // most months have 31 days
switch (m) {
case Date::february: // the length of February varies
days_in_month = (leapyear(y))?29:28;
break;
case Date::april: case Date::june: case Date::september: case Date::november:
days_in_month = 30; // the rest have 30 days
break;
}
if (days_in_month<d) returnfalse;
returntrue;
}
And here's where I declared it in my header...
1 2
bool bad_date(int y, Date::Month m, int d); //bad_date finds valid dates
bool leapyear(int y);