直到并包括 Delphi 10.0 Seattle,您可以使用类助手来访问strict protected
和strict private
成员,如下所示:
unit Shy;
interface
type
TShy = class(TObject)
strict private
procedure TopSecret;
private
procedure DirtyLaundry;
protected
procedure ResistantToChange;
end;
unit NotShy;
interface
uses
Shy;
type
TNotShy = class helper for TShy
public
procedure LetMeIn;
end;
implementation
procedure TNotShy.LetMeIn;
begin
Self.TopSecret;
Self.DirtyLaundry;
Self.ResistantToChange;
end;
end.
uses
..., Shy, NotShy;
procedure TestShy;
var
Shy: TShy;
begin
Shy := TShy.Create;
Shy.LetMeIn;
Shy.Free;
end;
但是,从 Delphi 10.1 Berlin 开始,这不再有效!类助手不能再访问strict protected
,strict private
或private
成员。这个“功能”实际上是Embarcadero 现在在柏林修复的编译器错误。你运气不好。