Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#7

AW: Fehlende Mehrfachvererbung bei Schnittstellen

  Alt 17. Jul 2014, 19:05
Als Ergänzung vielleicht noch: So würde ich es in Java machen:

Code:
class App
{
   public static void main (String[] args) throws java.lang.Exception
   {
      IBoth myVar = new BothImplementer();
      myVar.subMethod1();
      myVar.subMethod2();
   }
}

interface IBase {
   // Stub
}

interface ISub1 extends IBase {
   void subMethod1();
}

interface ISub2 extends IBase {
   void subMethod2();
}

// Reines Tagging-Interface
interface IBoth extends ISub1, ISub2 {}

// Muss das Tagging-Interface implementieren
class BothImplementer implements ISub1, ISub2, IBoth {
   public void subMethod1() {
      System.out.println("submethod1");
   }
   public void subMethod2() {
      System.out.println("submethod2");
   }
}
In Delphi ist die Deklaration von IBoth nicht möglich.
  Mit Zitat antworten Zitat