作者:mobiledu2502891023 | 来源:互联网 | 2022-12-01 15:29
这个delphi代码是可编译的,并按预期工作.
program RaiseLabel;
uses FastMM4, Windows, StdCtrls;
function CreateLabel(const S: string): TLabel;
begin
Result := TLabel.Create(nil);
Result.Caption := S;
end;
begin
try
raise CreateLabel('Strange exception example');
except
on L: TLabel do begin
MessageBox(0, PChar(L.Caption), 'TLabel', MB_OK);
end;
end;
end.
我的问题是,为什么异常处理不仅限于引发异常对象,它是异常类的后代.(我在完全调试模式下使用FastMM来测试此程序是否会导致任何内存泄漏 - 但事实并非如此.)