-1
我用Delphi XE3和 我不明白爲什麼下面的第一投沒有編譯:(德爾福仿製藥無效的轉換
type
TBase = class
end;
TDerived = class(TBase)
end;
procedure cast();
var
bases : TObjectList<TBase>;
deriveds : TObjectList<TDerived>;
begin
bases := deriveds; // specific to generid, Here !
deriveds := bases; // generic to specific, ok should not compile as is !
end;
是'TDerived'類應該延長'TBase'類似於'TDerived = class TBase)'? – fantaghirocco
@fantaghirocco同樣會發生,如果是這樣的話。 –
FWIW閱讀我關於這個問題的文章:ht tp://delphisorcery.blogspot.de/2014/10/generics-and-variance.html –