Jump to content
wuwuxin

Is Delphi Interface "polymophic"?

Recommended Posts

IMyInterfaceBase = interface

  procedure A;

  procedure B;

end;


IMyInterface = interface(IMyInterfaceBase)

  procedure C;

  procedure D;

end;


intf_1: IMyInterfaceBase

intf_2: IMyInterface;

Are the following lines legitimate?

 

(intf_1 as intf_2).C();

 

Edited by wuwuxin

Share this post


Link to post
6 hours ago, wuwuxin said:

Are the following lines legitimate?

 


(intf_1 as intf_2).C();

 

No. Because you need type for as operator.

 

(intf_1 as IMyInterface).C;

But you also need to add GUID to your interface declaration because without it it cannot be identified.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×