我今天正在测试一些东西,我注意到即使没有创建实例,您也可以访问对象的布尔类型属性。这怎么可能?当尝试修改布尔属性时,会引发 AV。
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TTest = class(TObject)
public
bBool : Boolean;
end;
TForm4 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.FormCreate(Sender: TObject);
var t : TTest;
begin
if t.bBool then
ShowMessage('what????');//this message is showed
t.bbool := false; //AV...
end;
end.