background image

  (2)object adapter 

     三、实现

  和其他很多模式一样,学习设计模式的重点是学习每种模式的思想,而不应拘泥于它的某种具体结构图和实现。因为模

 

式是灵活的,其实现可以是千变万化的,只是所谓万变不离其宗。 在 STL 中大量运用了 Adapter 模式,象 function 

adapter、iterator adpter,它们与这里说的 adapter 结构并不一样,但思想是一样的。具体的介绍可到侯捷网站上找相关文

 

章,他讲得非常好。

  四、示例代码

  (1)class adapter 

namespace DesignPattern_Adapter

{

// class Adaptee