摘要: class View{public: // Interface. void Display() { SetFocus(); DoDisplay(); ResetFocus(); } void SetFocus() { cout <<"View::SetFocus" <<endl; } void ResetFocus() { cout <<"View::ResetFocus" <<endl; }private: // logic. virtual void... 阅读全文
posted @ 2013-02-06 11:59 walfud 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Strategy 和 State 模式极为相似, 唯一的不同就是 Strategy 侧重于对操作进行抽象, 而 State 侧重于将数据进行抽象.关于 State 模式, 请见:http://www.cnblogs.com/walfud/articles/2901855.html 阅读全文
posted @ 2013-02-06 11:33 walfud 阅读(127) 评论(0) 推荐(0) 编辑
摘要: class State{public: // Interface. virtual void foo() = 0; virtual void bar() = 0;};class StateVer0 : public State{public: // Interface. virtual void foo() override { cout foo(); } void bar() { //// Unmaintainable! //switch (m_ver) //{ //case 0: ... 阅读全文
posted @ 2013-02-06 11:06 walfud 阅读(172) 评论(0) 推荐(0) 编辑
摘要: class Originator;class Memento{ // data. int m_x, m_y; friend class Originator;private: Memento(int x, int y) : m_x(x), m_y(y) {}};class Originator{ // data. int m_x, m_y;public: Originator(int x, int y) : m_x(x), m_y(y) {}public: // Interface. void Move(int x, int y) {... 阅读全文
posted @ 2013-02-06 10:35 walfud 阅读(163) 评论(0) 推荐(0) 编辑