Expected initializer before int


full code here - https://linkpicture.com/q/help_5.jpg


So i cant't figure out how tofix my code my code.
It shows error (expected initializer before int) at int day, month, year; line.


void Date::displayDate(){
cout<<month<<"/"<<day<<"/"<<year<<endl;
}
int main()

int day, month, year;
char c;
cout << "Enter a start date: " << endl;
cin >> month >> c >> day >> c >> year;

date start = date(month, day, year);
cout << "Enter an end date: " << endl;
cin >> month >> c >> day >> c >> year;

date end = date(month, day, year);
int duration = end-start;
cout << "The number of days between those two dates are: " << duration << endl;


return 0; }
Last edited on
<> on the editor is the code tag thing, but <> isnt how you do it typed in the forum. use [code type tags in [] brackets instead.

you do appear to be missing a { after main

this is a case of the compiler got confused, the error code didnt match the issue. Compilers struggle to give a good message on mismatched brackets in general.
Last edited on
Registered users can post here. Sign in or register to post.