Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple inheritance for interfaces

Is there a way to define an interface who inherits from two or more interfaces?

I tried the following code on Delphi2007:

  IInterfaceA = interface
     procedure A;
  end;

  IInterfaceB = interface
    procedure B;
  end;

  IInterfaceAB = interface(IInterfaceA, IInterfaceB);

.. and it raised an E2029 error:

E2029 ')' expected but ',' found

at line:

IInterfaceAB = interface(IInterfaceA, IInterfaceB).

like image 775
Fabrizio Avatar asked Nov 10 '16 14:11

Fabrizio


1 Answers

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)
like image 152
Uwe Raabe Avatar answered Sep 21 '22 16:09

Uwe Raabe