Adapter
范式是一個(gè)
Class
,
Object Structural
范式。
簡單說就是嫁接。從類層次圖的設(shè)計(jì)原則來說,就是該干什么的就讓它干什么,需要協(xié)作時(shí),組合它們。
class
Shape {????? ?????? //
一個(gè)接口
?????? virtual void BoundBox() const = 0;
?????? virtual ~Shape() {};
};
?
/*
*
一個(gè)抽象類,作為
TextShape
的
Helper
,對
TextShape
表示的文本進(jìn)行文
*
本化編輯
*/
class
TextView {
};
?
class
TextShapeAdapter : public Shape, protected TextView {????? //
一個(gè)
Adapter
};
?
class
TextShapeAdaptee : public Shape {?? ?????? //
一個(gè)
Adaptee
??????
protected
:
??????
?????? TextView _helper;
};
posted on 2006-07-10 17:03
靜靜的流水 閱讀(450)
評論(1) 編輯 收藏 引用 所屬分類:
Design Patterns