Autor Beitrag
seppel86
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54



BeitragVerfasst: So 06.03.05 17:03 
Hi, hab mal wieder ein vermutlich lächerliches, trotzdem für mich unverständliches Problem. Ich hab eine Klasse definiert und in der Klasse einige Variablen deklariert, beim kompilieren erhalte ich folgenden fehler:
"[Error] gameobject.pas(10): Published field 'ym' not a class nor interface type".
Was mach ich falsch?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
type Tgo = class(TPanel)
        xm,ym : integer;
        public
                Constructor Create(Aowner: TComponent; ps:string; pi,pl,pt:integer);
                Destructor Destroy;
                procedure getx;
                procedure gety;
end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 06.03.05 17:06 
Mach mal ein private vor dem xm,ym : integer rein, dann sollte es klappen.
seppel86 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54



BeitragVerfasst: So 06.03.05 17:15 
Er nimmts an, danke. Ich hab aber schon lauffähige programme geschrieben ohne diese variablen als private zu deklarieren. Woran liegt das?
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: So 06.03.05 17:24 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  Tgo = class(TPanel)
  public
    xm,ym: Integer;
    Constructor Create(Aowner: TComponent; ps:string; pi,pl,pt:integer);
    Destructor Destroy;
    procedure getx;
    procedure gety;


So geht es auch. Der Abschnitt vor dem ersten public (bzw. private oder protected) gehört Delphi, nicht dir.
seppel86 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54



BeitragVerfasst: So 06.03.05 17:28 
Herrlich dieses Forum. Hier lernt man mehr als im Infounterricht. :D
Da hat mein Lehrer mal wieder Müll erzählt.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 06.03.05 17:34 
wdbee hat folgendes geschrieben:
So geht es auch. Der Abschnitt vor dem ersten public (bzw. private oder protected) gehört Delphi, nicht dir.

Der erste Abschnitt ist published, und dort kannst du keine Variablen deklarieren. Wenn du es unbedingt published haben willst (willst du aber nicht ;)), dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
 private
  Fxm,Fym : integer;
 published
  property xm : Integer read Fxm write Fxm;

Die Variablen xm und ym solltest du unter private(/protected) haben nicht unter public! Das sind klasseninterne Variablen. Wie ich sehe hast du ja die Funktionen getx und gety.