Autor Beitrag
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 14.06.03 21:30 
Hallo,

wenn ich eine Klasse habe, und den Konstruktor überscheribe, muss ich ja Inherited aufrufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
constructor TSomething.Create;
begin
  Inherited Create;
  { ... };
end;

Muss ich das "Create" hinter "Inherited" schreiben, oder geht es auch ohne, also so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
constructor TSomething.Create;
begin
  Inherited;
  { ... };
end;

Das gleiche gilt aichfür den Destruktor: Muss ich "Inherited Destroy" oder nur "Inherited" schreiben???

Oder mal anders gefragt: WAS MACHT INHERITED EIGENTLICH? Wenn ich jetzt Inherited aufrufe, weiß Delphi dann selbst, was ich da vererben will, also dass ich im Destruktor die Original-Methode aufrufen will oder dass ich bei 'ner Message den Original-Handler haben will, oder muss ich das immer explizit angeben? So wie ich das verstanden habe, rift Iherited ja nur die überschreibene Methode auf, und das gibt es ja immer nur eine. Das wäre sowit verstanden, aber wozu steht dann in der Online-Hilfe der Name der Original-Methode?


Moderiert von user profile icontommie-lie: Code- durch Delphi-Tags ersetzt

_________________
Life is a bad adventure, but the graphic is really good!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 14.06.03 21:53 
Titel: Re: Konstruktor: "Inherited" oder "Inherited
Hallo,
Andreas Pfau hat folgendes geschrieben:
Oder mal anders gefragt: WAS MACHT INHERITED EIGENTLICH?

wenn du C++ kannst läst es sich am besten so erklähren: "Inherited ist der Scope Operator ( :: )".

Das geht aber auch ausführlicher:
Inherited ruft eine Methode des Vorfahren der Aktuellen kasse auf. Wenn du keine Methode angiebst, dann wird die aufgeruden die genauso heißt wie die aktuelle (in welcher der Aufruf steht) und die selben Parameter werden übergeben.
Wenn dein neuer Construktor also genauso aufgebaut ist wie der alte (selbe Parameter) dann musst du ncihts hinter Inherited angeben, wenn er sich unterscheidet (oder du eine andere Prozedure/Funktion aufrufen willst) musst du einen Entsprechenden Aufruf hinter das Schöüsselwort schreiben.

Gruß
Klabautermann
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 14.06.03 22:45 
:D Wow, das war genau auf den Punkt gebracht! Danke! :D

_________________
Life is a bad adventure, but the graphic is really good!
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 15.06.03 17:29 
Und an dieser Stelle folgt dann wiedermal der Hinweis auf meine Ausarbeitung über OOP in Delphi: www.***.de ;)

Moderiert von user profile iconTino: Link entfernt da dieser nicht mehr erreichbar.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: So 15.06.03 18:25 
Hallo,

danke für den Link, werde es mir mal in Ruhe durchlesen.

_________________
Life is a bad adventure, but the graphic is really good!
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Do 26.06.03 17:46 
Hallo,

@Motzi, sorry, hat etwas länger gedauert, bis ich deinenn OOP-Text gelesen habe. Interessant, vor allem das mit dem "T" vor Klassennamen. Kannst du das geneauer erklären, warum ein T davor ist, nur ungarisch sagt mir jetzt nix. Gibt's im ungarischen ein bestimmtes wort, das mit T anfängt? Welches? Diese Frage stelle ich mir nämlich schopn lange, was dieses "T" bedeutet.

Übrigens... "P" steht ja wohl für "Pointer", "I" für "Interface", "H" für "Handle", oder? z.B. "PChar", "IUnknown", "HWnd".

_________________
Life is a bad adventure, but the graphic is really good!
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 26.06.03 18:44 
Klassendefinitionen werden mit type eingeleitet, kurz t, deshalb das T davor :wink:
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Do 26.06.03 19:19 
Hallo,

aber in dieser Doku stand was von ungarischer Schreibweise... :?!?:

_________________
Life is a bad adventure, but the graphic is really good!
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 27.06.03 18:45 
Bin auch mal wieder kurz da... fahr aber morgen schon wieder weg ;)

@Andreas: was du meinst ist die ungarische Notation... die besagt eben, dass bestimmte Namen einen bestimmten Präfix haben. Eben T weil Type und alles mögliche andre was du eh schon erwähnt hast... das ganze heißt ungarische Notation weil es von einem Chef-Entwickler von M$ eingeführt wurde und der war eben Ungar ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Fr 27.06.03 20:03 
Hallo,

ach so ist das, ich dachte, das "T" wäre aus einem ungarischen Wort. Dann hat @UGrohne natürlich Recht, sorry :oops:

_________________
Life is a bad adventure, but the graphic is really good!