Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 05.07.07 13:57 
Kann mir einer erklären, wie ich eine komplett neue Oberklasse erstelle, ohne dass diese von einer anderen Klasse etwas erbt?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 14:07 
Gar nicht. selbst wenn du keine angibst wird TObject genommen

_________________
Markus Kinzler.
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 05.07.07 14:11 
:(
Kann man es denn dann wenigstens "abstellen", dass die Klasse von ihrer Oberklasse etwas erbt?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 14:13 
Nein, weil es für die RTL/VCL wichtig ist, daß alle Klassen ein vorgebenes Grundverhalten haben.

_________________
Markus Kinzler.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 05.07.07 14:36 
Was genau willst du denn erreichen? Was stört dich an TObject?

_________________
Bravery calls my name in the sound of the wind in the night...
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 05.07.07 14:59 
Ich möchte eine komplett neue Klasse mit eigenen Propertys und so machen. Die von TObject will ich da nich drin haben.. ^^

Nebenfrage:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type
Klasse= class(TObject)
EinWort: string;
property Wort: string read EinWort;
procedure test;

end;


Auf einer Internetseite stand, dass man so Propertys deklarieren kann. Aber irgendwie kann ich auf dieses Property in meiner "Test"-Prozedur nicht zugreifen.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Do 05.07.07 15:03 
Du kannst auf sie nur lesend zugreifen.
Wenn du noch ein write hinzufügst, kannst du das auch beschreiben:
ausblenden Delphi-Quelltext
1:
property Wort: string read EinWort write EinWort; //bei read und write kann stattdessen auch eine Methode verwendet werden					


Gruß
alias5000

_________________
Programmers never die, they just GOSUB without RETURN
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:04 
Zitat:
Die von TObject will ich da nich drin haben.
Wie gesagt, geht nicht.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
type
Klasse = class
private
  EinWort: string;
public
  procedure test;
published 
  property Wort: string read EinWort;


Was meinstdu mit, kannst nicht zugreifen?

_________________
Markus Kinzler.
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 05.07.07 15:18 
user profile iconmkinzler hat folgendes geschrieben:
Was meinstdu mit, kannst nicht zugreifen?


Wenn ich schreibe "Klasse." erscheint mein neues Property nicht in der Liste.

Und wenn ich "Klasse.Wort:='jo';" schreibe, sagt Delphi, dass ein "Method Identifier" erwartet wird...

Aktuell hab ich das so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
Klasse= class(TObject)
EinWort: string;
property Wort:string read EinWort write EinWort;
procedure test;
end;
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:21 
Die Fragen wurde beide (von Heilbronnern) beantwortet: Es wird nicht angezeigt, weil nicht published und du kannst nicht verändern, weil du die Property als readonly angelegt hast.

_________________
Markus Kinzler.
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 05.07.07 15:22 
Du musst eine Instanz deiner Klasse erstellen.
ausblenden Delphi-Quelltext
1:
var aKlasse: Klasse;					

Und dann mit aKlasse arbeiten.

Lies mal das
www.dsdt.info/grundl...rache/oo.php?search=

MfG
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 05.07.07 15:39 
user profile iconCoder hat folgendes geschrieben:
Du musst eine Instanz deiner Klasse erstellen.
ausblenden Delphi-Quelltext
1:
var aKlasse: Klasse;					

Und dann mit aKlasse arbeiten.


Ja so gehts! :) Hatte völlig vergessen, dass das mit var Form1:TForm1 ja auch immer so war. ^^

Danke an alle!
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Do 05.07.07 17:34 
aus Gründen der Abwärtskompatibilität zu ObjectPascal unterstützt Delphi immer noch "Objekte". Diese Klassen haben wirklich nur die Methoden, die du deklarierst. Vererbung gibt es allerdings schon!

Die Deklaration sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TMyObject = object
    Variable: integer;
    function Datum: TDate;
  end;


Diese Objekte musst du nicht instantiieren. Das geht automatisch, indem du eine Variable dieses Types deklarierst. Die Methoden implementierst du wie bei Klassen. Eigenschaften (propertys) gibt es nicht, nur Variablen.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 17:36 
Würde ich aber nicht mehr verwenden.

_________________
Markus Kinzler.