### Weird declaration error.

Hey fellas, sorry for asking so many questions lately, hopefully this is the final piece to my puzzle..
I get an error that reads :
main.cpp: In function ‘int main()’:
main.cpp:290:4: error: ‘days’ was not declared in this scope

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485`` `````` //----------Makin' Text----------- vectorcalspots; vectorstrings(42, ""); int m1 = 130; int n = 220; int daycount = 0; if (h==0) { daycount=6; m1=1030; } if (h==1) { daycount=0; m1=130; } if (h==2) { daycount=1; m1=280; } if (h==3) { daycount=2; m1=430; } if (h==4) { daycount=3; m1=580; } if (h==5) { daycount=4; m1=730; } if (h==6) { daycount=5; m1=880; } for (int i = 0; i < 31; ++i) { Point *d = new Point(m1, n); calspots.push_back(*d); ++daycount; if (daycount == 7) { m1 = 130; daycount = 0; n += 100; } else { m1 += 150; } } if ( m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12) { for (int i = 0; i < 31; ++i) { string Result; ostringstream convert; convert << i+1; Result = convert.str(); Text *days = new Text(calspots[i], Result); days->set_font_size(15); cal.attach(*days); } } if ( m==4 || m==6 || m==9 || m==11) { for (int i = 0; i < 30; ++i) { string Result; ostringstream convert; convert << i+1; Result = convert.str(); Text *days = new Text(calspots[i], Result); days->set_font_size(15); cal.attach(*days); } } if ( m==2) { for (int i = 0; (i < 29) && (y%4==0); ++i) { string Result; ostringstream convert; convert << i+1; Result = convert.str(); (calspots[i], Result); days->set_font_size(15); cal.attach(*days); } } else { for (int i = 0; i < 28; ++i) { string Result; ostringstream convert; convert << i+1; Result = convert.str(); Text *days = new Text(calspots[i], Result); days->set_font_size(15); cal.attach(*days); } } for (int i = 0; i==e.Day || m==e.Month || y==e.Year;"") { Text *days = new Text(calspots[i], e.name); days->set_font_size(15); cal.attach(*days); }``````

The problem code is right here...
 ``1234567891011`` `````` if ( m==2) { for (int i = 0; (i < 29) && (y%4==0); ++i) { string Result; ostringstream convert; convert << i+1; Result = convert.str(); (calspots[i], Result); days->set_font_size(15); cal.attach(*days); } }``````

It tells me I haven't declared it, but no other functions above or below throw an error using nearly verbatim syntax.
Erm, have u tried to declare it?
It is declared, it works for the other functions.
Hmm could it be this?
`Text *days = new Text(calspots[i], e.name);`
All your other functions have a line like the above, but in the function u highlighted it doesn't.
Compare it to the other if statements about the value of m. Notice how they say something along the lines of:

` Text *days = new Text(calspots[i], Result);`

compared to this if statement, which does not? The others work because you declare days in the loop themselves- in this case, you don't. Hence why it doesn't work.
Topic archived. No new replies allowed.