我正在尝试在Delphi 2009中实现以下示例代码中的“clear”功能。
interface
...
TFoo<T : IInterface> = class(TObject)
FField : T;
procedure Clear;
end;
...
implementation
...
procedure TFoo<T>.Clear;
begin
// Line Below Results In
// E2010 Incompatible types: 'T' and 'Pointer'
FField := nil;
end;
...
我能理解如果“T”没有被限制会出现编译时错误。但既然“T”必须是一个接口,我本以为这个语法会起作用。
有没有办法将FField设置为NIL,以便释放接口呢?