gpt4 book ai didi

delphi - 复合 "with"语句中的名称解析如何工作?

转载 作者:行者123 更新时间:2023-12-03 15:18:05 33 4
gpt4 key购买 nike

以下代码中测试了 Ready 的哪个实例,为什么?

interface

type
TObject1 = class
...
public
property Ready: boolean read FReady write FReady;
end;

TObject2 = class
...
public
property Ready: boolean read FReady write FReady;
end;

implementation

var
Object1: TObject1;
Object2: TObject2;

...

procedure test;
var
Ready: boolean;
begin
Ready:= true;
with Object1, Object2 do begin
if Ready then ShowMessage('which one?');
end; {with}
end;

最佳答案

最后一个。

with Object1, Object2 do

相当于

with Object1 do
with Object2 do

因此 Object2 将是第一优先级。

The official documentation on this matter.

关于delphi - 复合 "with"语句中的名称解析如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6024007/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com