Hallo,
ich habe eine kleine Klasse erstellt bekomme jedoch bei Compilieren immer einen "Declaration syntax error", aber ich weis nicht warum! Eigentlich sollte da keiner kommen.
Der Fehler kommt in Zeile 2 und 18. Im Code habe ich sie mal rot makiert! Ich dachte erst es liegt am Namen der Klasse, aber wenn ich ihn ändere kommt immer noch der gleich fehler. Ich benutze den Borland Compiler Turbo C^^
Mit freundlichem Gruß
Konobi
ich habe eine kleine Klasse erstellt bekomme jedoch bei Compilieren immer einen "Declaration syntax error", aber ich weis nicht warum! Eigentlich sollte da keiner kommen.
Code:
#include <graphics.h>
class kugeln
{
private:
int feindcol(int, int);
int farbek, radk;
int col, cxvor, cyvor;
int cx, cy;
public:
void feind();
kugeln();
~kugeln();
void setWerte(int, int, int, int);
};
kugeln::kugeln(){}
kugeln::~kugeln(){}
void kugeln::setWerte(int cxu, int cyu, int rad, int farbe){
cx=cxu;
cy=cyu;
farbek=farbe;
radk=rad;
}
void kugeln::feind(){
delay(50);
int i;
int rnd;
setcolor(0);
circle(cx, cy, radk);
col=feindcol(cx, cy);
switch (col){
case 1: rnd=(random(10)+2); cx+=rnd; cy+=rnd; cxvor=rnd; cyvor=rnd; break;
case 2: rnd=(random(10)+2); cx-=rnd; cy+=rnd; cxvor=-rnd; cyvor=rnd; break;
case 3: rnd=(random(10)+2); cx-=rnd; cy-=rnd; cxvor=-rnd; cyvor=-rnd; break;
case 4: rnd=(random(10)+2); cx+=rnd; cy-=rnd; cxvor=rnd; cyvor=-rnd; break;
case 0: cx+=cxvor; cy+=cyvor; break;
}
setcolor(farbek);
circle(cx,cy, radk);
setcolor(3);
}
int kugeln::feindcol(int cirx, int ciry){
int col=0;
if (cirx==35)
col=1;
else if (ciry==35)
col=2;
else if (cirx==605)
col=3;
else if (ciry==445)
col=4;
else col=0;
return col;
}
Der Fehler kommt in Zeile 2 und 18. Im Code habe ich sie mal rot makiert! Ich dachte erst es liegt am Namen der Klasse, aber wenn ich ihn ändere kommt immer noch der gleich fehler. Ich benutze den Borland Compiler Turbo C^^
Mit freundlichem Gruß
Konobi