我真的很困惑。爲什麼不在我的Delphi對象上調用_AddRef和_Release?
// initial class
type
TTestClass =
class(TInterfacedObject)
end;
{...}
// test procedure
procedure testMF();
var c1, c2 : TTestClass;
begin
c1 := TTestClass.Create(); // create, addref
c2 := c1; // addref
c1 := nil; // refcount - 1
MessageBox(0, pchar(inttostr(c2.refcount)), '', 0); // just to see the value
end;
它應該顯示1,但它顯示0.無論我們要執行多少任務,值都不會改變!爲什麼不?
thx肯,它的確如此......我錯過了接口的使用權,這是我的史詩般的失敗:(但是我已經學會了這一切,我的餘生... – Focker 2010-10-13 03:38:38