Autor Beitrag
marvin190
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 18:57 
Hallo zusammen!

Ich habe mal eine Frage, ich habe ein Procedure, das ausgelöst wird, wenn auf einen Button geklickt wird

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.GetInfosClick(Sender: TObject);
begin
  //Atome erstellen
  Element1 := TAtom.Create(StrToInt(E1NameEdt.Text));
  ...
end;


Zur Erklärung: Element1 ist vom Typ TAtom. Nun soll in "Element1" ein TAtom erstellt werden und dieser eine Parameter wird mitgegeben (Typ: Integer).

Das Procedure zu dem vverwiesen wird, sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
constructor TAtom.Create(Value: Integer);
begin
  inherited Create;
  ElementenNr := Value;
...
end;


Jetzt gibt der Kompiler in der Zeile "Element1 := TAtom.Create(StrToInt(E1NameEdt.Text));" eine Felher "Zu viele Parameter" aus.

Darf ich vielleicht einem Create-Procedure keine Variabele zuweisen?

Danke schonmal für eure Hilfe!

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 03.05.06 19:01 
Wie sieht der Konstruktor der Superklasse aus?

_________________
Markus Kinzler.
marvin190 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 19:02 
Welcher Superklasse?

TForm oder TAtom?

TAtom steht oben.

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 03.05.06 19:05 
Du rufst im Konstruktor von TAtom ja mit dem inherited den Konstruktor dessen Superklasse auf. Wie ist dieser definiert?

_________________
Markus Kinzler.
marvin190 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 19:13 
Achso, nein die Superklasse existiert nicht mehr, aber auch wenn ich jetzt das inherited wegmache, geht zwar der Fehler auch nicht weg, aber der Compiler akzeptiert das Create alleine nicht (Nicht genügend wirkliche Parameter). Brauc hich das Create vielleicht gar nicht mehr?


Danke schonmal für die schnelle Antwort!

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 03.05.06 19:17 
Ja, wenn es keine Superklasse mehr gibt brauchst du die ganze Zeile nicht mehr.

_________________
Markus Kinzler.
marvin190 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 19:19 
Ok, bleibt immernoch das "Zu viele Parameter" Problem!

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 03.05.06 19:27 
Poste mal die gesamte Definition der Klasse TAtom.

_________________
Markus Kinzler.
marvin190 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 19:33 
Die Definition von TAtom:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
TAtom = class(TObject)
  public
    // Felder
    AtomName: String;       // Name des Atoms
    AtomAbk: String;        // Kürzel des Atoms
    ElementenNr: Integer;   // Elementen Nummer


    // Bindungen
    VorgaengerAtom:TAtom;
    BindungsListe: TList; // Bindungen weiter unten in der Ordnung
    AtomListe: TList;
    // Methoden
    constructor Create(Value: Integer); // Elementennummer
    destructor Destroy;
  end;

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 03.05.06 19:52 
Ich kann da eigentlich keinen Fehler erkennen. hast du mal versucht das Create mit einer Konstante aufzurufen oder den Wert des Edits in einer Variablen zwischenzuspeichern?

_________________
Markus Kinzler.
marvin190 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 55

Win XP, SuSe Linux 10.1
Delphi 3/5/2005 Personal; C++ Builder 6
BeitragVerfasst: Mi 03.05.06 19:59 
alles klar, so funktioniert es, sieht zwar nicht schön aus... aber was solls! :-)

Danke für eure Hilfe!

_________________
Mfg Marvin
Carpe Diem! - Genieße den Tag! - [gr. Horaz]