[C++ Error] Unit1.cpp(12): E2141 Declaration syntax error
03.04.2016, 21:35. Показов 3152. Ответов 4
Здравствуйте! Это моя первая тема, поэтому простите за ошибки и неточности.
Суть вопроса в том, что проект компилировался, работал и вдруг начал выдавать ошибку.
Я прошу сейчас постараться ответить, ЧТО не нравится компилятору в "TForm *Form1" (12 строка)?
Unit1.cpp:
C++ | 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
| //---------------------------------------------------------------------------
#include <vcl.h>
#include <typeinfo.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm *Form1;
int X1,X2,Y1,Y2,frb;
int i=0, j=0, v=0, h=0;
aggregation a,b;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button4->Enabled = true;
if (i>=1) Button5->Enabled = true;
Button8->Enabled = true;
Button6->Enabled = true;
Button7->Enabled = true;
Button12->Enabled = true;
Button13->Enabled = true;
randomize();
X1=Form1->Shape2->Width+random(Form1->ClientWidth-Form1->Shape2->Width);
Y1=random(Form1->ClientHeight);
if (X1+50>Form1->ClientWidth) X1-=50;
if (Y1+50>Form1->ClientHeight) Y1-=50;
X2=X1+48+random(Form1->ClientWidth-X1-48-3);
Y2=Y1+48+random(Form1->ClientHeight-Y1-48-3);
frb = random(19);
a.p[i] = new oval(X1,Y1,X2,Y2,frb);
i++;
v++;
Edit1->Text = v;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Button4->Enabled = true;
if (i>=1) Button5->Enabled = true;
Button8->Enabled = true;
Button6->Enabled = true;
Button7->Enabled = true;
Button12->Enabled = true;
Button13->Enabled = true;
randomize();
X1=Form1->Shape2->Width+random(Form1->ClientWidth-Form1->Shape2->Width);
Y1=random(Form1->ClientHeight);
if (X1+50>Form1->ClientWidth) X1-=50;
if (Y1+50>Form1->ClientHeight) Y1-=50;
X2=X1+48+random(Form1->ClientWidth-X1-48-3);
Y2=Y1+48+random(Form1->ClientHeight-Y1-48-3);
frb = random(19);
a.p[i]=new rechteck(X1,Y1,X2,Y2,frb);
i++;
v++;
Edit1->Text = v;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
exit(0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
j=Edit1->Text.ToInt()-1;
if ((v!=i)&&(j>0)) j+=b.wie_viele-1;
int i1, i2, j1, j2;
if((v!=i)&&(j==0))
while(h<1000)
{
b.bewegen(1,1,-1);
for (int w = 0; w<=i-1; w++)
if (w!=j)
{
if(a.p[w]->schneiden(a.p[j]))
{
a.p[w]->set_farbe();
a.p[j]->set_farbe();
}
a.p[w]->zeigen();
}
h++;
}
else
{
while(h<1000) a.p[j]->bewegen(1,1);
h++;
}
h=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
for (j=0; j<i; j++)
{b.verbinden(a.p[j]);
b.p[b.wie_viele+j]=a.p[j];}
b.wie_viele=i;
Form1->Edit1->Text = 1;
v=1;
Button12->Enabled = false;
Button13->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
for (j=0; j<i; j++) delete a.p[j];
i=0;
j=0;
v=0;
Form1->Edit1->Text = 0;
b.wie_viele=0;
Canvas->Pen->Width=3;
Canvas->Pen->Color=Form1->Color;
Canvas->Brush->Color=Form1->Color;
Canvas->Rectangle(Shape2->Width,0,Form1->ClientWidth,Form1->ClientHeight);
ReleaseDC(Handle, Canvas->Handle);
Button4->Enabled = false;
Button5->Enabled = false;
Button8->Enabled = false;
Button11->Enabled = false;
Button12->Enabled = false;
Button13->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
j=Edit1->Text.ToInt();
if (j>=2) j--; else j=v;
Edit1->Text = j;
Canvas->Brush->Color=Form1->Color;
Canvas->Brush->Style=bsSolid;
for (int w=0; w<i; w++)
a.p[w]->zeigen();
Canvas->Brush->Style=bsClear;
for (int w=0; w<i; w++)
a.p[w]->zeigen();
Canvas->Brush->Style=bsDiagCross;
Canvas->Brush->Color=clBlack;
if (b.wie_viele>0)
if(j==1)
for (int w=0; w<b.wie_viele; w++)
a.p[w]->zeigen();
else a.p[j-2+b.wie_viele]->zeigen();
else a.p[j-1]->zeigen();
Canvas->Brush->Color=Form1->Color;
Canvas->Brush->Style=bsClear;
if ((b.wie_viele>0) && (j==1))
{
Button12->Enabled = false;
Button13->Enabled = false;
Button11->Enabled = true;
} else
{
Button12->Enabled = true;
Button13->Enabled = true;
Button11->Enabled = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
j=Edit1->Text.ToInt();
if (j<=v-1) j++; else j=1;
Edit1->Text = j;
Canvas->Brush->Color=Form1->Color;
Canvas->Brush->Style=bsSolid;
for (int w=0; w<i; w++)
a.p[w]->zeigen();
Canvas->Brush->Style=bsClear;
for (int w=0; w<i; w++)
a.p[w]->zeigen();
Canvas->Brush->Style=bsDiagCross;
Canvas->Brush->Color=clBlack;
if (b.wie_viele>0)
if(j==1)
for (int w=0; w<b.wie_viele; w++)
a.p[w]->zeigen();
else a.p[j-2+b.wie_viele]->zeigen();
else a.p[j-1]->zeigen();
Canvas->Brush->Color=Form1->Color;
Canvas->Brush->Style=bsClear;
if ((b.wie_viele>0) && (j==1))
{
Button12->Enabled = false;
Button13->Enabled = false;
Button11->Enabled = true;
} else
{
Button12->Enabled = true;
Button13->Enabled = true;
Button11->Enabled = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
v=i;
b.wie_viele = 0;
Button11->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button12Click(TObject *Sender)
{
j=Edit1->Text.ToInt()-1;
a.p[j]->verstecken();
a.p[j]->set_farbe();
randomize();
a.p[j]->x2=a.p[j]->x1+48+random(Form1->ClientWidth-
a.p[j]->x1-48-a.p[j]->****e);
a.p[j]->y2=a.p[j]->y1+48+random(Form1->ClientHeight-
a.p[j]->y1-48-a.p[j]->****e);
for (int w=0; w<i; w++) a.p[w]->zeigen();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button13Click(TObject *Sender)
{
j=Edit1->Text.ToInt()-1;
if (strcmp(typeid(*a.p[j]).name(),"rechteck")==0)
a.p[i++] = new rechteck(a.p[j]->x1,a.p[j]->y1,a.p[j]->x2,a.p[j]->y2,
a.p[j]->farbe);
else
if (strcmp(typeid(*a.p[j]).name(),"oval")==0)
a.p[i++] = new oval(a.p[j]->x1,a.p[j]->y1,a.p[j]->x2,a.p[j]->y2,
a.p[j]->farbe);
v++;
Edit1->Text = v;
}
//--------------------------------------------------------------------------- |
|
Unit1.h:
C++ | 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
| //---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <math.h>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
#include <jpeg.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TButton *Button2;
TButton *Button3;
TButton *Button8;
TButton *Button4;
TShape *Shape2;
TButton *Button5;
TLabel *Label1;
TCheckBox *CheckBox1;
TEdit *Edit1;
TButton *Button6;
TButton *Button7;
TButton *Button11;
TButton *Button12;
TButton *Button13;
TButton *Button14;
TButton *Button15;
TButton *Button16;
TButton *Button17;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall Button4Click(TObject *Sender);
void __fastcall Button5Click(TObject *Sender);
void __fastcall Button8Click(TObject *Sender);
void __fastcall Button6Click(TObject *Sender);
void __fastcall Button7Click(TObject *Sender);
void __fastcall Button11Click(TObject *Sender);
void __fastcall Button12Click(TObject *Sender);
void __fastcall Button13Click(TObject *Sender);
void __fastcall Button14Click(TObject *Sender);
void __fastcall Button15Click(TObject *Sender);
void __fastcall Button16Click(TObject *Sender);
void __fastcall Button17Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
class shape
{
public:
friend TForm;
int ****e;
int x1, y1, x2, y2, farbe;
int cx,cy;
shape(){cx=cy=1; ****e = 3;};
~shape(){};
shape(int c1,int d1,int c2,int d2, int f)
{
x1=c1;
x2=c2;
y1=d1;
y2=d2;
****e=3;
cx=cy=1;
farbe = f;
}
void set_farbe(int &f)
{
switch(f)
{
case 0: Form1->Canvas->Pen->Color=(TColor)RGB(0,0,0); break;
// и так до 18.
}
}
void set_farbe()
{
randomize();
farbe = random(19);
set_farbe(farbe);
}
virtual void zeigen() {};
virtual void verstecken() {};
void bewegen(int x_b, int y_b)
{
if (!(Form1->CheckBox1->Checked)) verstecken();
x1+=cx*x_b; //
x2+=cx*x_b;
y1+=cy*y_b;
y2+=cy*y_b;
zeigen();
for (long int p = 0; p<160000; p++) {p++; p--;}
};
bool schneiden(shape* right)
{
return (!((y1>right->y2)||(y2<right->y1)||(x2<right->x1)||(x1>right->x2)));
}
shape* operator=(shape* t)
{
x1=t->x1;
y1=t->y1;
x2=t->x2;
y2=t->y2;
cx=t->cx;
cy=t->cy;
set_farbe(t->farbe);
****e=t->****e;
return this;
}
};
class oval : public shape
{
public:
oval():shape(){};
oval(int c1, int d1, int c2, int d2, int f):shape(c1,d1,c2,d2,f)
{
set_farbe(f);
Form1->Canvas->Pen->Width=****e;
Form1->Canvas->Brush->Style=bsClear;
Form1->Canvas->Ellipse(x1,y1,x2,y2);
};
void verstecken()
{
Form1->Canvas->Pen->Width=****e;
Form1->Canvas->Pen->Color=Form1->Color;
Form1->Canvas->Ellipse(x1, y1, x2, y2);
}
void zeigen()
{
Form1->Canvas->Pen->Width=****e;
set_farbe(farbe);
Form1->Canvas->Ellipse(x1, y1, x2, y2);
}
~oval(){};
};
class rechteck : public shape
{
// я превысил лимит символов!
};
class aggregation: public shape
{
public:
shape** p;
int wie_viele;
aggregation():shape()
{
wie_viele = 0;
x1=y1=100000;
x2=y2=0;
}
void verbinden(shape* right)
{
x1 = (x1<right->x1)? x1:right->x1;
x2 = (x2>right->x2)? x2:right->x2;
y1 = (y1<right->y1)? y1:right->y1;
y2 = (y2>right->y2)? y2:right->y2;
}
~aggregation(){};
void zeigen()
{
for(int w=0; w<wie_viele; w++)
p[w]->zeigen();
}
void verstecken()
{
for(int w=0; w<wie_viele; w++)
p[w]->verstecken();
}
void bewegen(int x_b, int y_b, int h)
{
if (h>=0)
{
if (Form1->CheckBox1->Enabled == false)
for (int w=0; w<wie_viele; w++) p[w]->verstecken();
for (int w=0; w<wie_viele; w++)
{
if (((p[w]->x2+(x_b*p[w]->cx)+****e+1)>Form1->ClientWidth)||
((p[w]->x1+(x_b*p[w]->cx)-p[w]->****e-1)<
Form1->Shape2->Width))
for (int u=0; u<wie_viele; u++) p[u]->cx*=-1;
if (((p[w]->y2+(y_b*p[w]->cy)+****e+1)>Form1->ClientHeight)||
((p[w]->y1+(y_b*p[w]->cy)-****e-1)<0))
for (int u=0; u<wie_viele; u++) p[u]->cy*=-1;
p[w]->bewegen(x_b,y_b);
}
}
else
{
if (((p[h]->x2+(x_b*p[h]->cx)+****e+1)>Form1->ClientWidth)||
((p[h]->x1+(x_b*p[h]->cx)-p[h]->****e-1)<
Form1->Shape2->Width)) p[h]->cx*=-1;
if (((p[h]->y2+(y_b*p[h]->cy)+****e+1)>Form1->ClientHeight)||
((p[h]->y1+(y_b*p[h]->cy)-****e-1)<0)) p[h]->cy*=-1;
p[h]->bewegen(x_b,y_b);
}
for (int w=0; w<wie_viele-1; w++)
for (int u=w+1; u<wie_viele; w++)
if(p[w]->schneiden(p[u]))
{
p[u]->set_farbe();
p[u]->set_farbe();
}
};
} |
|
0
|