Hi I am very new at programming im trying to " Write a program to determine whether a date is valid in terms of days in that month." I thought I fixed all the bugs but now I just get
1 2 3
/tmp/ccethkpa.o(.text+0x11d): In function `main':
: undefined reference to `Date::Date()'
collect2: ld returned 1 exit status
i have no idea how to go about fixing this, or even what it means. If anyone could help me or point me in the right direction I would be very appreciative. Thanks!
#include<iostream>
usingnamespace std;
class Date
{
private:
int month, date, year;
public:
Date();
Date( int mm, int dd, int yyyy)
{
month = mm;
date = dd;
year = yyyy;
}
int valid_Date( int month, int date, int year )
{
switch( month )
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if( date >= 01 && date <= 31 )
{
cout << "The date " << month << "/" << date << "/" << year << " is valid." << endl;
};
break;
case 2:
if( date >= 01 && date <= 28 )
{
cout << "The date " << month << "/" << date << "/" << year << " is valid." << endl;
}
elseif( date == 29 && (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)))
{
cout << "The date " << month << "/" << date << "/" << year << " is valid." << endl;
};
break;
case 4:
case 6:
case 9:
case 11:
if( date >= 01 && date <= 30 )
{
cout << "The date " << month << "/" << date << "/" << year << " is valid." << endl;
};
break;
default:
cout << "The date " << month << "/" << date << "/" << year << " is not valid." << endl;
}
}
};
int main()
{
int mn, dt, yr;
Date test_date;
cout << "Enter month: ";
cin >> mn;
cout << "\nEnter date: ";
cin >> dt;
cout << "\nEnter year: ";
cin >> yr;
cout << endl;
test_date.valid_Date( mn, dt, yr );
return 0;
}