Delphi:Create()构造函数结尾处的访问冲突 [英] Delphi: Access Violation at the end of Create() constructor

查看:249
本文介绍了Delphi:Create()构造函数结尾处的访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本和简单的类:

I have a very basic and simple class like this:

unit Loader;

unit Loader;

interface

uses
  Vcl.Dialogs;

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

implementation

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

end;

end.

而从Form1我就这样调用:

And from Form1 i call it like this:

procedure TForm1.Button1Click(Sender: TObject);
var
 the : TLoader;
begin
  the := the.Create;
end;

现在,就在之后:= the.Create part,delphi显示消息与'ok'然后给我一个错误,并说 Project Project1.exe引发异常类$ C0000005与消息访问冲突0x0040559d:读取地址0xffffffe4'。

Now, just after the the := the.Create part, delphi shows the message with 'ok' and then gives me an error and says 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.

我是delphi的新手。我使用的是Delphi XE2,我无法解决这个错误。有没有人告诉我一条路径或有解决之道?

I am new at delphi. I am using Delphi XE2 and i couldnt manage to fix this error. Does anyone show me a path or have solution for this?

推荐答案

var
  the : TLoader;
begin
  the := the.Create;

不正确。应该是

var
  the : TLoader;
begin
  the := TLoader.Create;

这篇关于Delphi:Create()构造函数结尾处的访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆