클래스의 상속과 Interface
인터페이스에 부모 세대와 동일 메소드 선언시,
해당 인터페이스의 구현체(인스턴스)는, 부모 메소드를 호출합니다.
program Project5; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type TAClass = class(TInterfacedObject) procedure Foo; end; IFooBar = interface ['{016E8951-FF3A-486A-8C90-66A8C77708A7}'] procedure Foo; procedure Bar; end; TBClass = class(TAClass, IFooBar) procedure Bar; end; { TAClass } procedure TAClass.Foo; begin WriteLn('Foo'); end; { TBClass } procedure TBClass.Bar; begin WriteLn('Bar'); end; var LB: IFooBar; begin LB := TBClass.Create; LB.Foo; LB.Bar; ReadLn; end.
실행결과
Foo Bar