Board index » delphi » Interface calling another interface's method?

Interface calling another interface's method?

Can an Interface call a method from another interface?  How is it
done?

 

Re:Interface calling another interface's method?


Quote
Lito Dizon wrote in message <34e5075d.142360...@forums.borland.com>...
>Can an Interface call a method from another interface?  How is it
>done?

No, and the question doesn't really make sense as asked.  An interface is
nothing but a contract--it has no code--and makes no calls itself.  The
object that implements the interface can have an arbitrary amount of code
that implements a given method, and that code can call out via other
interfaces.

Also, if the object that implements your interface also implements another
interface, and the two interfaces define an identical method, the object
implementing the interfaces can route both those interface methods to the
same actual implementing code.  This is done by using the "method renaming"
feature of Object Pascal, which allows you to say something like this:
  function IPersistPropertyBag.Load = PropBagLoad;
inside the class declaration for an object.  Assuming this object declares
IPersistPropertyBag in its interface section, this statement means that
whenever a client calls the object via the IPersistPropertyBag.Load method,
it will actually invoke this object's PropBagLoad method.

-- Conrad Herrmann

Other Threads