[fpc-pascal] Out of scope method?
Ryan Joseph
ryan at thealchemistguild.com
Thu Apr 6 11:56:45 CEST 2017
> On Apr 6, 2017, at 4:30 PM, Tony Whyman <tony.whyman at 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
More information about the fpc-pascal
mailing list