hi guys,
can someone HELP
I have a class that receives a start date and end date
(ie. as 12 11 2005) and I have to print out the dates in between
in form 12 November 2005.
I have various functions that convert the date etc. but am stuck with defining
operator++
I really can't find any example that shows this.
Here is what I have and the errors:
MY CODE:
THE Errors:Code:void date::operator++(date& oldDate)
{
unsigned maxDaysInMonth, maxDaysInFeb;
unsigned dayOfMonth=oldDate.getDay();
unsigned monthOfYear=oldDate.getMonth();
unsigned myYear=oldDate.getYear();
if (oldDate.isLeapYear(myYear))
maxDaysInFeb=29;
else
maxDaysInFeb=28;
switch(monthOfYear)
{
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
maxDaysInMonth=31;
case 4: case 6: case 9: case 11:
maxDaysInMonth=30;
case 2:
maxDaysInMonth=maxDaysInFeb;
default:
break;
}
if (maxDaysInMonth=dayOfMonth)
{
oldDate.setDay(1);
if (monthOfYear=12)
{
oldDate.setMonth(1);
oldDate.setYear(myYear+1);
}
else
{
oldDate.setMonth(monthOfYear+1);
oldDate.setYear(myYear);
}
}
else
{
oldDate.setDay(dayOfMonth+1);
oldDate.setMonth(monthOfYear);
oldDate.setYear(myYear);
}
}
Code:date.h:35: error: postfix `void date::operator++(date&)' must take `int' as its
argument
date.cpp:135: error: postfix `void date::operator++(date&)' must take `int' as
its argument
I know this would be pretty straight forward but how can i make it work?
thanks