摘要: #include <iostream> #include <memory> class Strategy { public: virtual void show() = 0; }; class Context { public: void setStrategy(std::shared_ptr<St 阅读全文
posted @ 2022-02-25 18:16 南乡水 阅读(17) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <list> #include <memory> class AbstractObserver { public: virtual void update(std::string msg) = 0; }; class AbstractSubj 阅读全文
posted @ 2022-02-25 18:15 南乡水 阅读(5) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> class Context; class State { public: virtual void handle1(Context *c) = 0; virtual void handle2(Context *c) = 0; 阅读全文
posted @ 2022-02-25 18:15 南乡水 阅读(18) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> #include <vector> class Momento { public: Momento(std::string state) { this->state_ = state; } std::string state 阅读全文
posted @ 2022-02-25 18:14 南乡水 阅读(24) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> class Mediator { public: virtual void Notify(std::string Msg) = 0; }; class BaseComponent { public: virtual void 阅读全文
posted @ 2022-02-25 18:13 南乡水 阅读(20) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> #include <vector> template <typename T, typename U> class Iterator { public: virtual U cur() = 0; virtual void n 阅读全文
posted @ 2022-02-25 18:02 南乡水 阅读(16) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> class Reciever { public: void op1() { std::cout << "In Reciever op1()." << std::endl; } void op2() { std::cout < 阅读全文
posted @ 2022-02-25 17:59 南乡水 阅读(22) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> class Handler { public: virtual void handle(int data) = 0; virtual void setNextHandler(std::shared_ptr<Handler> 阅读全文
posted @ 2022-02-25 17:58 南乡水 阅读(30) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> class Subject { public: virtual void show() = 0; }; class RealSubject : public Subject { public: void show() ove 阅读全文
posted @ 2022-02-25 17:54 南乡水 阅读(13) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <memory> #include <unordered_map> class Flyweight { public: Flyweight(int data) : data_(data) {} void show() { std::cout 阅读全文
posted @ 2022-02-25 17:52 南乡水 阅读(13) 评论(0) 推荐(0) 编辑