Autor Beitrag
Sinic
Hält's aus hier
Beiträge: 8

Win XP Home
D3 Prof, D6 Pers
BeitragVerfasst: Do 10.03.05 15:59 
Ich hab ein Problem mit meiner Objektklasse. In der Schule unter Delphi 4 lief sie einwandfrei, aber bei Delphi 6 kommt ein Fehler: [Error] UObjklbruch.pas(13): '=' expected but identifier 'zaehler' found

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
unit UObjklbruch;


interface

uses

  SysUtils, StdCtrls, Dialogs;

type
  TBruch = Class(TObject);
  private
    zaehler: WORD;
    nenner: WORD;
    ganzzahl: WORD;
    vorzeichen: Char;

was soll denn an dem zaehler: WORD; falsch sein :?!?:


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Do 10.03.2005 um 23:47
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Do 10.03.05 16:15 
Also bei mir funktioniert der Code-Schnipsel wunderbar. ;) Bringt keinen Fehler.

Poste doch auch mal den Rest, obwohl ich mir irgendwie nicht wirklich vorstellen kann, dass da irgendwas nicht stimmt, was sich auf die Privat-Declarations auswirkt. :gruebel:

Ansonsten kannst du auch einfach mal probieren, deinen Code-Schnipsel in einem völlig leeren Programm auszuführen also ungefähr so:
ausblenden Delphi-Quelltext
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    zaehler: WORD;
    nenner: WORD;
    ganzzahl: WORD;
    vorzeichen: Char;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
thebe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP Home
D6 Enterprise
BeitragVerfasst: Do 10.03.05 18:08 
ausblenden Delphi-Quelltext
1:
TBruch = Class(TObject);					


Also mir schmeckt z.B. das Semikolon daran nicht wenn direkt danach die Klassenfelder etc. deklariert werden. Ein Semikolon hinter diese Zeile kommt nur wenn wenn man Klassen Vordeklarieren will.

Sprich:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
TBla = class(irgendwas);
TBla2 = class(TBla);

TNochirgendwas = class(sowieso);

TBla = class(irgendwas)
    private
        fNenFeld: boolean;
    public
        fNeProcedure(Blubber: integer);
end;

TBla2 = class(TBla)
[..]