Adapter 如果客户需要使用某个类的服务,而这项服务是这个类用一个不同的接口提供的,那么,可以使用适配器模式为客户提供一个期望的接口

类适配器:

客户程序定义好的接口
已经存在的类
类适配器
客户程序调用
对象适配器:
用户程序已经使用的类

客户程序通过把要适配的类标记为Virtula,使得我们有机会重载它。但这样做有可能存在风险。

客户程序
对象适配器
The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
posted @ 2007-01-04 17:26  南守拥  阅读(289)  评论(1编辑  收藏  举报