Autor Beitrag
[r2d2]
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

WinXP
D5 Enterprise
BeitragVerfasst: Mi 03.12.03 18:37 
Hallo
Ich habe mir folgende Klasse erstellt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
TObj = class
 cfg:Integer;
 ...
 procedure laba(fgz:real);
 procedure doblablabla(xyz:Integer);
 ...
end;


Jetzt will eine weitere klasse, nämlich TSObj, die alle Proceduren, Funktionen und Variablen von TObj hat und mit der ich auch die gleichen Operationen ausführen kann wie mit TObj, Ich müsste also auch in Prozeduren, in denen ich eine Variable vom Typ TObj übergebe eine Variable vom Typ TSObj übergeben können.

Sowas geht doch mit Vererbung, oder? Ich hab davon blos gar keine Ahnung :cry:


Zuletzt bearbeitet von [r2d2] am Mi 03.12.03 23:41, insgesamt 1-mal bearbeitet
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mi 03.12.03 18:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
TObj = class
 cfg:Integer;
 ...
 procedure laba(fgz:real);
 procedure doblablabla(xyz:Integer);
 ...
end;

TSObj = class(TObj)
  .
  .
  .
end;
[r2d2] Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

WinXP
D5 Enterprise
BeitragVerfasst: Mi 03.12.03 22:43 
lol, is ja einfach :lol:

danke
[r2d2] Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

WinXP
D5 Enterprise
BeitragVerfasst: Mi 03.12.03 23:39 
Ich hätte noch eine Frage, sie hat aber nicht direkt mit dem topic zu tun. Wie kriegt man sowas denn zum laufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
TAtype = record
 B: TBtype;
end;

TBtype = record
 A: TBtype;
end;
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Do 04.12.03 09:47 
Ich nehme mal an, Du meinst im 2. Record: A: TAtype.

In diesem Fall, solltest Du mit Klassen statt der Records arbeiten. Dazu brauchst Du nur record durch class ersetzen und für TBtype eine forward-Deklararion zu schreiben.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
TBtype = class;

TAtype = class 
 B: TBtype; 
end

TBtype = class 
 A: TAtype; 
end;


barfuesser
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 04.12.03 12:38 
Anscheinend hast du noch generelle Probleme mit OOP... schau dir vielleicht meine Ausarbeitung darüber an: www.x-spy.net/personal

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!