Mmmm, I haven't got time right now to try it, but that's not the behaviour
I'd expect.

I'd have hoped the compiler would pick that up, as it appears to with your
second example.

Interesting, can't explain it...

C.

-----Original Message-----
From: Todd Martin [mailto:[EMAIL PROTECTED]

However I noticed one very peculiar aspect of interfaces along the way when
compiling.

If I define a procedure
DoSomething(AObject : IFirstDescendant);
and
TNewClass = class(TInterfacedObject,ISecondDescendant);

and then the following code compiles okay

procedure Test;
var
MyObject : ISecondDescendant;
begin
  MyObject := TNewClass.Create;
  DoSomething(MyObject);
end;

I haven't checked yet, but I'm assuming the MyObject passed through to
procedure DoSomething() is then "nil", since TNewClass doesn't support
IFirstDescendant. Would that be your guess too? So why does it compile? On
the otherhand, does the ISecondDescendant pointer get sucessfully converted
to a IFirstDescendant pointer, in which case, why does
MyObject.QueryInterface(IFirstDescendant,FirstObject) return a "nil" pointer
to FirstObject?

However, if I define
IFirstDescendant = interface(IInterface);
ISecondDescendant = interface(IInterface);

ie. no interface inheritance - (or whatever you want to call it)
and

TNewClass = class(TInterfacedObject,IFirstDescendant,ISecondDescendant);

the Test() procedure does not compile. Any comments?
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to