When a class implements a descendant interface, why doesn't it automatically count as implementing the base interface?

后端 未结 2 1077
星月不相逢
星月不相逢 2020-12-15 20:47

What\'s the reason this won\'t compile?

type
  IInterfaceA = interface [\'{44F93616-0161-4912-9D63-3E8AA140CA0D}\']
    procedure DoA;
  end;

  IInterfaceB          


        
2条回答
  •  轮回少年
    2020-12-15 21:05

    Another way to make it work is to include both interfaces in the class declaration.

    TImplementsAB = class(TSingletonImplementation, IInterfaceA, IInterfaceB)
      procedure DoA;
      procedure DoB;
    end;
    

    I guess this is what is required for the compiler to realize that TImplementsAB implements both IInterfaceA and IInterfaceB.

提交回复
热议问题