Hallöchen!
Ich habe ein kleines Problem bei der OOP in Delphi - ich habe hierzu in der Suche nichts gefunden und auch in diversen OOP Tutorials keine Antwort erhalten...
Ich habe mit OOP gerade erst angefangen und bis jetzt noch kein lauffähiges OOP-Programm zustande gebracht, da ich, sobald ich irgendwie auf Variablen zugreifen will eine Schutzverletzungsmeldung von Windows bekomme und das Programm abstürzt.
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: 29: 30: 31:
| unit UStatistik;
interface
type TStatistik = class private Messwert: Array[1..10000] of Integer; Anzahl: Integer; function GetAnzahl : Integer; public constructor Create; procedure Add(value: Integer); procedure Sort; function GetMin : Integer; function GetMax : Integer; function GetMedium : Real; function GetValue(index: Integer) : Integer; property Count: Integer read GetAnzahl; end;
implementation
constructor TStatistik.Create; begin Anzahl:=0; end;
[...]
end. |
In meiner Hauptunit definiere ich
Statistik: TStatistik als globale Variable und versuche diese mit dem
FormCreate-Event zu "createn"... Nun bekomme ich bei Programmstart folgende Fehlermeldung:
Project OOP.exe raised exception class EAccessViolation with message 'Access violation at address 00428B12 in module 'OOP.exe' ...
Kann mir jemand helfen? Hab das Gefühl das es ein sehr trivialer Fehler ist - finde ihn aber nicht und stehe am Rande des Nervenzusammenbruches...
Danke schonmal im vorraus.
Mfg