[fpc-pascal] Is it posible to implement more than one interface in a class defination?

Florian Klaempfl florian at freepascal.org
Sun Nov 14 18:17:33 CET 2010


Sven Barth schrieb:
>>     * No name resolution (function aliases) of conflicting interfaces
> 
> Ehhh... the following code compiles with 2.4.2 and even 2.4.0:

Typical FUD tactics: mix something people know being true with something 
wrong and they believe you the wrong statement.

> var
>   t: TMyInterfacedObject;
>   i: IMyInterface;
> begin
>   t := TMyInterfacedObject.Create;
>   try
>     i := t;
>     t.Foo;
>     i.Foo;
>   finally
>     t.Free;
>   end;
> end.
> 
> ==== source end ====
> 
> Output is:
> 
> ==== output begin ====
> 
> Foo
> Bar
> An unhandled exception occurred at $08056B71 :
> EInvalidPointer : Invalid pointer operation
>   $08056B71
> 
> ==== output end ====
> 
> (I don't know currently where exactly that EInvalidPointer comes 
> from.... even a "t.AddRef" doesn't solve this...)

Releasing TInterfacedObject descendants by Free is a bad idea ;) It 
destroys the instance without checking if there are still queried 
interfaces.



More information about the fpc-pascal mailing list