Home Forums Programming help with codes, can’t spot mistakes Reply To: help with codes, can’t spot mistakes

#45689
Anonymous
Inactive

[code:1:33a8ff0200]#include"Date.h"
#include<iostream>
using namespace std;

int main()
{
Date date1(23,2,2010);//initialise a date with today’s date
Date date2;//define a date

//ask user to input date ie to define date2
int tmp;
cout<<"please input your date of birth"<<endl;
cout<<"year: ";
cin>> tmp;

//ask year to user until it is a valid year
//earlier on setyear()returns a false if user input invalid data

while(!date2.setyear(tmp)){
cout<<"Invalid year"<<endl<<"year:";
cin>> tmp;
}

cout<<"month:";
cin>>tmp;
//ask days to user until it is a valid day
while(!date2.setday(tmp)){
cout<<"Invalid month"<<endl<<"year:";
cin>>tmp;
}

cout<<"Today is:"date1.tostring()<<endl;
cout<<"you are"<<date1 – date2<<"days old1\n";

return 0;
}[/code:1:33a8ff0200]
ok i know i probably should figure out this error out myself, but i’ve been stuck for 15 minutes, so please somebody out there, help me!!
the error msg is:
error C2146: syntax error : missing ‘;’ before identifier ‘date1’
i checked around thayt area n it looks fine…
the error occurs at this line
[code:1:33a8ff0200]cout<<"Today is:"date1.tostring()<<endl;[/code:1:33a8ff0200]