随笔分类 -  设计模式

摘要:#include <iostream> #include <vector> using namespace std; class Light { public: void on() { cout << "灯亮了" << endl; } void off() { cout << "灯灭了" << en 阅读全文
posted @ 2023-12-20 15:44 泽良_小涛 阅读(5) 评论(0) 推荐(0) 编辑
摘要:一、代码示例 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 6 ///抽象一个Subject主题 7 ///观察者 8 class Observer { 9 public: 阅读全文
posted @ 2023-12-13 16:18 泽良_小涛 阅读(8) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 //设计思想:我们父类和子类就是一个扩展的关系?是不是合适 5 //里氏代换原则:子类对象就应该能完全替代父类的行为 6 //对于继承这样设计,特别小心,我们:组合大于继承 7 //把quack和fly 阅读全文
posted @ 2023-12-12 15:27 泽良_小涛 阅读(14) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 //PC机,手机,平板 5 class MakeOrder { 6 public: 7 //virtual void startOrder() =0;第一版 8 //钩子函数的模板方法 9 virtua 阅读全文
posted @ 2023-12-11 14:15 泽良_小涛 阅读(6) 评论(0) 推荐(0) 编辑
摘要:一、代码示例 #include <iostream> using namespace std; // //class Computer { //public: // void run(); //}; // //class HpWindows7 :public Computer { // //}; / 阅读全文
posted @ 2023-07-11 09:10 泽良_小涛 阅读(4) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <list> #include <string> using namespace std; //component class IFile { public: virtual void displaye() = 0; virtual int 阅读全文
posted @ 2023-06-21 09:48 泽良_小涛 阅读(5) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <sstream> using namespace std; template <class T> string MyConvertToStr(T obj) { stringstream ss; ss << obj; return ss.st 阅读全文
posted @ 2023-06-17 16:29 泽良_小涛 阅读(15) 评论(0) 推荐(0) 编辑
摘要:/* AOP:叫面向方面(切面)编程 在我们的日常开发中,我们经常会遇到这样的一类与业务逻辑无关 的开发,正交化 打log,将log进入织入我们的业务场景 */ #include <memory> #include <string> #include <iostream> using namespa 阅读全文
posted @ 2023-06-16 09:26 泽良_小涛 阅读(4) 评论(0) 推荐(0) 编辑
摘要:一、截图 二、代码示例 #include <iostream> #include <string> #include <vector> using namespace std; //棋子的颜色 enum PieceColor { BLACK, WHTIE }; //棋子的位置 struct Piec 阅读全文
posted @ 2023-06-09 11:57 泽良_小涛 阅读(4) 评论(0) 推荐(0) 编辑
摘要:一、代码示例 #include <iostream> using namespace std; class Carmera { public: void turnOn() { cout << "相机启动" << endl; } void turnOff() { cout << "相机关闭" << e 阅读全文
posted @ 2023-06-06 16:11 泽良_小涛 阅读(3) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; class ThreePhaseOutlet { public: void doThreePhasePlug() { cout << "三相插头接入" << endl; } }; class TwoPhaseOutle 阅读全文
posted @ 2023-05-24 14:06 泽良_小涛 阅读(6) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 #include <sstream> 4 #include <typeinfo> 5 using namespace std; 6 template <class T> 7 string iToStr(T val 阅读全文
posted @ 2023-05-19 09:43 泽良_小涛 阅读(5) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <sstream> 5 using namespace std; 6 7 template<class T> 8 string ConvertToStri 阅读全文
posted @ 2023-05-18 11:05 泽良_小涛 阅读(6) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 class FrameApi { 5 public: 6 virtual void draw() = 0; 7 protected: 8 FrameApi() {}; 9 }; 10 11 class 阅读全文
posted @ 2023-05-16 17:27 泽良_小涛 阅读(3) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> using namespace std; class ExportFileApi { public: virtual bool exportData(string data) = 0; protected: ExportFi 阅读全文
posted @ 2023-05-09 09:18 泽良_小涛 阅读(4) 评论(0) 推荐(0) 编辑
摘要:一、线程安全性的讲解 1、视频截图 2、线程安全性的代码 加不加临界区进行验证 #include <afxwin.h> #include <iostream> #include <stdio.h> using namespace std; CRITICAL_SECTION g_cs; class S 阅读全文
posted @ 2023-04-28 09:54 泽良_小涛 阅读(8) 评论(0) 推荐(0) 编辑
摘要:一、第一种方法 //实现了客户端调用和implOne,implTwo的解耦合//factory类实现了变化隔离 1 #include<string> 2 #include "DynOBJ.h" 3 using namespace std; 4 5 class Api { 6 public: 7 vi 阅读全文
posted @ 2023-04-26 18:33 泽良_小涛 阅读(3) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示