问题描述
我有一个非常基本和简单的类,如下所示:
I have a very basic and simple class like this:
单元加载器;
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 := the.Create
部分之后,delphi 显示带有 'ok'
的消息,然后给我一个错误并说 ProjectProject1.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 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() 构造函数末尾的访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!