Keep Getting Error

I'm trying to write an overloaded - function. Right now I keep getting an error at the else statement where I break into the second condition of the program.

// + operator overloading
int Date_Time::operator -(const Date_Time &right)
{
     int days_amount = 0, days_temp = 0 , max_day = 0, t_month = month, t_year = year;
 
	 if (year < right.year);
	 {
	 	while(t_year != right.year && t_month != right.month)
	 	{
			t_month = t_month + 1;
			if (month < 13)
			{ 
				if(t_month == 1 || t_month == 3 || t_month == 5 ||
	   			t_month == 7 || t_month == 8 || t_month == 10 ||
	   			t_month == 12)
				{
					max_day = 31;
				}	
				if (t_month == 4 || t_month == 6 || t_month == 9 || t_month == 11)
				{
					max_day = 30;
				}
				if (leap_year && t_month == 2)
				{
					max_day = 29;
				}
				else
					max_day = 28;
			
			   days_temp += max_day;
			}
			
			if (t_month == 13)
			{
				t_month = 1;
				t_year = t_year + 1;
			}	 	 
		} 
		
		if (day < right.day)
			days_amount = days_temp + abs(day - right.day);
		else 
			days_amount = days_temp - (day - right.day);	
		
		return days_amount;		
	 }
	 // HERE ERROR FLAGS
	 else
	 {
		while(t_year != right.year && t_month != right.month)
	 	{
			t_month = t_month + 1;
			if (t_month > 0)
			{ 
				if(t_month == 1 || t_month == 3 || t_month == 5 ||
	   			t_month == 7 || t_month == 8 || t_month == 10 ||
	   			t_month == 12)
				{
					max_day = 31;
				}	
				if (t_month == 4 || t_month == 6 || t_month == 9 || t_month == 11)
				{
					max_day = 30;
				}
				if (leap_year && t_month == 2)
				{
					max_day = 29;
				}
				else
					max_day = 28;
			
			   days_temp += maxday;
			}
			
			if (t_month == 0)
			{
				t_month = 12;
				t_year = t_year - 1;
			}	 	 
		} 
		
		if (day > right.day)
			days_amount = (days_temp + day)- right.day;
		else 
			days_amount = (days_temp + day) + abs(day - right.day);	
		
		return days_amount;	
	}
}


I'm really frustrated at this point, and I know it's probably something really small and stupid. I just can't think since I've been programming for the past 6 hours now.
The error I keep getting says expected primary expression before else.
Last edited on
Please use code tags. It makes it easier to refer to line numbers.

Here's your problem:

if (year < right.year);

Note the trailing semicolon.
You have a semicolon in after your first if statement.
Topic archived. No new replies allowed.