when i initialize zot with this date: 10,9,2002...it only picks up the month...10...but gets junk for the rest ....why do u think that is the case??
Thanks!
=======================
Date::Date(int mon, int day, int year):julianDate(0)
{
bool result;
result = isValidDate(mon,day,year);
if (result == 1)
{
month = mon;
day = day;
year = year;
};
}
=====================
bool
Date::
isValidDate(int month, int day, int year)
{
if (day < 1 || day > 31 || month < 1 || month > 12)
return false;
if (month == 2 && year%4 == 0 && day > 29)
return false;
if (month = 2 && year%4 != 0 && day > 28)
return false;
if (month == 4 || month == 6 || month == 9 || month == 11 && day > 30)
return false;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 && day > 31)
return false;
if (month = 0 && day == 0 && year == 0)
return true;
return true;
}
=====================
cout << "\ninitialization constructor Date zot(10,9,2002)";
Date zot(10,9,2002); // conversion constructor
cout << endl
<< zot
<< " zot "
<< endl;
==========================
if (month == 2 && year%4 == 0 && day > 29)
return false;
if (month = 2 && year%4 != 0 && day > 28)
return false;
month == 2 and day > 29 is wrong whatever be the year .. no need for any check at all .
also btw feb , 1900 is of 28 days :) so check the actual condition ..
also you have have the day, month , years as unsigned int to be on safer side