> On Apr 6, 2017, at 4:30 PM, Tony Whyman <tony.why...@mccallumwhyman.com> 
> wrote:
> 
> See http://freepascal.org/docs-html/current/ref/refse48.html#x101-1230007.7
> for an example.
> 
> See also http://wiki.freepascal.org/How_To_Use_Interfaces

"All COM interfaces use reference counting. This means that whenever an 
interface is assigned to a variable, it’s reference count is updated. Whenever 
the variable goes out of scope, the reference count is automatically decreased. 
When the reference count reaches zero, usually the instance of the class that 
implements the interface, is freed.”

Shouldn’t destroy be called in this example when TestScope exists?

type
        TScopeObject = class (TInterfacedObject)
                destructor Destroy; override;
        end;

destructor TScopeObject.Destroy;
begin
        writeln('dead');
        inherited Destroy;
end;

procedure TestScope;
var
        scope: TScopeObject; 
begin
        scope := TScopeObject.Create;
end;


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to