宽接口:
IInterFace1=interface
  //方法列表
end;

窄接口:对象接口,接口声明和类相似,但不能直接实例化,也不能自己实现它们的方法,而是由支持接口的类来提供实现。
type
  TStrategy=class(TObject)//抽象策略
  public
    procedure Hello;virtual;abstract;
  end;

  TContext=class(Tobject)//上下文
  private
    FStrategy:TStrategy;//引用已有的对象(窄接口)
    Procedure SetStrategy(Value:TStrategy);
  public
    procedure ContextInterface;//向已有的对象委派责任
    property Strategy:TStrategy read FStrategy write SetStrategy;
  end;  

相关文章:

  • 2021-03-31
  • 2021-07-04
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-01-07
  • 2021-08-26
  • 2021-12-31
相关资源
相似解决方案