I have a question regarding interface delegation and reference counting.
If a non interfaced object is extended with an interface and that interface uses
delegation to implement that interface then how is instance destruction detected
by the delegating class. Example below
if the following is done.
var
X : ITesting;
begin
X := TMyObject.Create;
end;
at the end of this the TTesting delegated object is destroyed but the Delegating object
(TmyObject) is not released. Suggestions. Classes and interfaces below. I am looking
at how delegation can assist in aggregation but am unsure about management of
instances.
type
ITesting = interface
function Test:String;
end;
TTesting = class(TInterfacedObject,ITesting)
public
function Test :String;
end;
TMyObject = class(TObject,ITesting)
private
FTesting :TTesting;
property Tst:TTesting read FTesting implements ITesting;
public
constructor Create;
end;
implementation
{ TTesting }
function TTesting.Test: String;
begin
result := 'Tested';
end;
{ TMyObject }
constructor TMyObject.Create;
begin
inherited;
FTesting := TTesting.Create;
end;
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz