Type
IMyInterface = Interface Function MyFunc : Integer; Function MySecondFunc : Integer; end; TMyClass = Class(TInterfacedObject,IMyInterface) Function MyFunc : Integer; Function MyOtherFunc : Integer; end; Function TMyClass.MyFunc : Integer; begin Result:=23; end; Function TMyClass.MyOtherFunc : Integer; begin Result:=24; end; |
will result in a compiler error:
Error: No matching implementation for interface method
"IMyInterface.MySecondFunc:LongInt" found |
At the moment of writing, the compiler does not yet support providing aliases for an interface as in Delphi. i.e. the following will not yet compile:
ype
IMyInterface = Interface Function MyFunc : Integer; end; TMyClass = Class(TInterfacedObject,IMyInterface) Function MyOtherFunction : Integer; // The following fails in FPC. Function IMyInterface.MyFunc = MyOtherFunction; end; |
This declaration should tell the compiler that the MyFunc method of the IMyInterface interface is implemented in the MyOtherFunction method of the TMyClass class.