Multiple inheritance for interfaces

There is no multiple interface inheritance in Delphi as there is no multiple inheritance in Delphi at all. All you can do is make a class implement more than one interface at once.

TMyClass = class(TInterfacedObject, IInterfaceA, IInterfaceB)

In Delphi interfaces cannot inherit multiple interfaces, but classes can implement multiple interfaces. If you design your components properly (look up ISP - interface segregation principle) you should not need to have interfaces inheriting from interfaces.


IMHO, in this case, you must define three types. One per interface and third for multiple inheritance :

  IInterfaceA = interface
     procedure A;
  end;

  IInterfaceB = interface
    procedure B;
  end;

  TiA = class(TInterfacedObject, IInterfaceA)
    procedure A;
  end;

  TiB = class(TInterfacedObject, IInterfaceB)
    procedure B;
  end;

  TMyObject = class(TInterfacedObject, IInterfaceA, IInterfaceB)
  private
    _iA : IInterfaceA;
    _iB : IInterfaceB;
    function getiA : IInterfaceA;
    function getiB : IInterfaceB;
  public
    property iA : IInterfaceA read getiA implements IInterfaceA;
    property iB : IInterfaceB read getiB implements IInterfaceB;
  end;
{.....}
{ TMyObject }

function TMyObject.getiA: IInterfaceA;
begin
  if not Assigned(_iA) then _iA := TIA.Create;
  Result := _iA;
end;

function TMyObject.getiB: IInterfaceB;
begin
  if not Assigned(_iB) then _iB := TIB.Create;
  Result := _iB;
end;