Множественное наследование


Множественного наследования в FPC нет, но зато есть интерфейсы,
которые могут помочь в имитации множественного наследования.

const
  XSetterInterface = '{3FB19775-F5FA-464C-B101-D8137D742088}';
  XGetterInterface = '{3FB19775-F5FA-464C-B101-D8137D742089}';

  ISetterInterface = interface
      [XSetterInterface]
      procedure SetValue(k,v:string);
  end;

  IGetterInterface = interface
      [XGetterInterface]
      function GetValue(k:string): string;
  end;

type

  THook = class(TObject, IGetter)
  end;

  TMyComponent = class(TComponent, ISetter, IGetter)
  ...
      // Direct implementation
      function GetValue(k:string):string;

      // Indirect implementation
      procedure SetMyOwnValue(k,v:string);
      procedure ISetterInterface.SetValue = SetMyOwnValue;

      // Implementation with property
  private
      // NEED: FHook := THook.Create;
      FHook: IGetter;
  public
      property Hook: IGetterInterface read FHook implements IGetterInterface;
  end;


var
  M: TMyComponent
  I: IGetterInterface;

begin

  M := TMyComponent.Create;

  if R.GetInterface(SGetterInterface, I) then
  begin
      v:=I.GetValue('key');
  end

end.