设计模式之 组合模式
class Graph { public: Graph(void); virtual ~Graph(void); public: virtual void bounds(const Rect&); virtual void draw(void); virtual void intersects(const Point &point); virtual void insert(Graph *graph); virtual Graph* getParent(void){ return NULL; } }; class Rectangle : public Graph { public: Rectangle(void); ~Rectangle(void); public: virtual void bounds(const Rect&); virtual void draw(void); virtual void intersects(const Point &point); }; class Composition: public Graph { public: Composition(void); virtual ~Composition(void); public: virtual void draw(void); virtual void insert(Graph *graph); protected: vector<Graph*> graphList_; vector<Compositor*> compositor_; }; class Compositor { public: Compositor(void); virtual ~Compositor(void); public: void setComposition(Composition *pCom); virtual void compose(void); }; class TextCompositor: public Compositior { public: TextCompositor(void); ~TextCompositor(void); public: virtual void compose(void); };