Hello guys
Hello guys,
Is there a way to a interface inherit from many other interfaces? For example:
public interface UserMethods {
}
public interface WallMethods {
}
public interface OpenreduAPI : UserMethods, WallMethods {
}
I can do this using C# and Java, but I was not able to achieve something similar with Delphi :(
I tried this:
IUserMethods = interface
end;
IWallMethods = interface
end;
IOpenreduAPI = interface(IUserMethods, IWallMethods)
end;
But it doesn't compile, multiple interface inheritance is very useful for compose REST API calls :D
Many thanks :D
Is there a way to a interface inherit from many other interfaces? For example:
public interface UserMethods {
}
public interface WallMethods {
}
public interface OpenreduAPI : UserMethods, WallMethods {
}
I can do this using C# and Java, but I was not able to achieve something similar with Delphi :(
I tried this:
IUserMethods = interface
end;
IWallMethods = interface
end;
IOpenreduAPI = interface(IUserMethods, IWallMethods)
end;
But it doesn't compile, multiple interface inheritance is very useful for compose REST API calls :D
Many thanks :D
No you can not do this, but when implementing a class it can implement multiple interfaces
ReplyDeleteYes, multiple interface inheritance is a nice feature. But it has never been developed for the Delphi compiler.
ReplyDeleteperhaps with includes
ReplyDeletetype
IUserMethods = interface
{$INCLUDE userMethods.inc}
end;
IWallMethods = interface
{$INCLUDE userMethods.inc}
{$INCLUDE WallMethods.inc}
end;
IOpenreduAPI = interface
{$INCLUDE userMethods.inc}
{$INCLUDE WallMethods.inc}
{$INCLUDE OpenreduAPI.inc}
end;
but you still have to specify the 3 interfaces if you want to query them
TMyClass = class(TInterfacedObject, IUserMethods, IWallMethods, IOpenreduAPI)
end;
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!
ReplyDeletePaul TOTH your example does not need this ugly hack. you can simply do:
ReplyDeleteIUserMethods = interface;
IWallMethods = interface(IUserMethods);
IOpenreduApi = interface(IWallMethods)
oups, too early before coffee :/
ReplyDeletetype
IUserMethods = interface
{$INCLUDE userMethods.inc}
end;
IWallMethods = interface
/////// {$INCLUDE userMethods.inc}
{$INCLUDE WallMethods.inc}
end;
IOpenreduAPI = interface
{$INCLUDE userMethods.inc}
{$INCLUDE WallMethods.inc}
{$INCLUDE OpenreduAPI.inc}
end;
A bit of history why Delphi does not have it (the last paragraph): http://edn.embarcadero.com/article/29779
ReplyDeleteIndeed Stefan Glienke is right: because COM heritage. Too bad they still cannot cut themselves loose from that.
ReplyDelete