Entwickler-Ecke

Delphi Language (Object-Pascal) / CLX - Merkwürdige Access Violation


GuaAck - Mi 03.08.11 23:00
Titel: Merkwürdige Access Violation
Hallo Experten,

der Code ist doch eine vollkommen normale Konstruktion, aber warum die ACCESS VIOLATION?
(Den Code habe ich exact in der dargestellten Version getestet.)

Vielleicht gewinne ich ja einen Preis für das "kürzeste abstürzende Delphi 7 Programm", aber lieber wäöre mir ein Tipp von Euch.

Gruß
GuaAck



Delphi-Quelltext
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
PROGRAM Fehlertest;

USES
  Forms,
  UFehlertest IN 'UFehlertest.pas' {Form1},
  UHashs IN 'UHashs.pas';

{$R *.res}

BEGIN
  application.Initialize;
  application.CreateForm(TForm1, Form1);
  application.Run;
END.

{=========================================}
UNIT UHashs;

INTERFACE

TYPE
  tHashs = CLASS
    CONSTRUCTOR Create;
  PUBLIC
    anzahl: integer;
  END;

IMPLEMENTATION

CONSTRUCTOR tHashs.Create;
BEGIN
  anzahl := 0;    { <<<<< Hier Access Violation }
END;
END.
{=========================================}

UNIT UFehlertest;

INTERFACE

USES
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UHashs;

TYPE
  TForm1 = CLASS(TForm)
    PROCEDURE FormCreate(Sender: TObject);
  PRIVATE
    { Private-Deklarationen }
  PUBLIC
    hash_zu_EG: tHashs;
    { Public-Deklarationen }
  END;

VAR
  Form1: TForm1;

IMPLEMENTATION

{$R *.dfm}

PROCEDURE TForm1.FormCreate(Sender: TObject);
BEGIN
  hash_zu_EG.Create;
END;
END.


Moderiert von user profile iconMartok: Delphi-Tag repariert


SvenAbeln - Mi 03.08.11 23:44


Delphi-Quelltext
1:
2:
3:
4:
PROCEDURE TForm1.FormCreate(Sender: TObject);
BEGIN
  hash_zu_EG:= tHashs.Create;
END;


GuaAck - Do 04.08.11 08:29

DANKE, wie kann ich nur so blind sein!!!!!
Gruß GuaAck