[fpc-pascal] Is it posible to implement more than one interface in a class defination?
pascaldragon at googlemail.com
Sun Nov 14 18:27:32 CET 2010
On 14.11.2010 18:17, Florian Klaempfl wrote:
>> t: TMyInterfacedObject;
>> i: IMyInterface;
>> t := TMyInterfacedObject.Create;
>> i := t;
>> ==== source end ====
>> Output is:
>> ==== output begin ====
>> An unhandled exception occurred at $08056B71 :
>> EInvalidPointer : Invalid pointer operation
>> ==== 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
You're right of course...
The following code flow works:
t := TMyInterfacedObject.Create;
i := t;
But why doesn't the following?
t := TMyInteracedObject.Create;
i := t;
i := Nil; // shouldn't this solve the problem as well? or is this a
problem of temp inteface variables?
More information about the fpc-pascal