相关疑难解决方法(0)

Delphi:Create()构造函数末尾的访问冲突

我有一个非常基本和简单的类,如下所示:

装载机;

interface

uses
  Vcl.Dialogs;

type
  TLoader = Class(TObject)
  published
      constructor Create();
  end;

implementation

{ TLoader }    
constructor TLoader.Create;
begin
   ShowMessage('ok');

end;

end.
Run Code Online (Sandbox Code Playgroud)

从Form1我称之为:

procedure TForm1.Button1Click(Sender: TObject);
var
 the : TLoader;
begin
  the := the.Create;
end;
Run Code Online (Sandbox Code Playgroud)

现在,在the := the.Create部件之后,delphi显示消息,'ok'然后给我一个错误并说Project Project1.exe raised exception class $C0000005 with message 'access violation at 0x0040559d: read of address 0xffffffe4'.

它也显示了这一行:

constructor TLoader.Create;
begin
   ShowMessage('ok');

end; // <-------- THIS LINE IS MARKED AFTER THE ERROR.
Run Code Online (Sandbox Code Playgroud)

我是德尔福的新手.我正在使用Delphi XE2,我无法设法修复此错误.有没有人给我看路径或有解决方案?

delphi delphi-xe2

7
推荐指数
2
解决办法
5621
查看次数

标签 统计

delphi ×1

delphi-xe2 ×1