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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    //----------Makin' Text-----------
  vector<Point>calspots;
  vector<String>strings(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...
1
2
3
4
5
6
7
8
9
10
11
	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.