Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread cobines
OK, I understand now. Thank you for explanation. -- cobines ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
On 30 Jan 11, at 22:28 , cobines wrote: > it is now a pointer to IBaseInterface, because of implicit QueryInterface? The reference changes because you have explicitly cast (the implementing object) to another interface. > So, I think I can compare interface variables but first I have to > bring

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
A more detailed answer: iDesc holds TDescClass as IDescInterface iBase holds TDescClass as IDescInterface iBaseAsBase holds TBaseClass as IBaseInterface iBase holds the IDescInterface interface because they are compile-time compatible (the same as an ancestor object reference holding an object f

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread cobines
2011/1/31 Andrew Hall : > Interfaces do not behave like classes.  Each each interface > implemented/supported by a class is unique - at runtime a "descendent" > interface is entirely unrelated to its ancestor. Ok, so in this assignment var iBase: IBaseInterface; iDesc: IDescInterface; begin

Re: [fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread Andrew Hall
Interfaces do not behave like classes. Each each interface implemented/supported by a class is unique - at runtime a "descendent" interface is entirely unrelated to its ancestor. Regards Andrew. On 30 Jan 11, at 20:37 , cobines wrote: > Hello everyone, > > I have attached a program about wh

[fpc-pascal] Casting descendant interface variables to base

2011-01-30 Thread cobines
Hello everyone, I have attached a program about which I have a question. Why does iBase have different value than iBaseAsBase? It seems simply assigning to interface variable doesn't change it to base interface, I have to explicitly use "as IBaseInterface". Is it correct? Basically, I'm trying t