随笔分类 - 设计模式DP
摘要:示例一 #include <stdio.h> #include <string.h> #include <stdlib.h> // 定义子系统A typedef struct subsystemA { void (*operationA)(struct subsystemA* subsystem);
阅读全文
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> // 定义业务处理者抽象类 typedef struct Handler { struct Handler* nextHandler; void (*handleRequest)(s
阅读全文
摘要:静态结构体数组式构建 链表式构建 链接式构建 #include <stdio.h> #include <stdlib.h> #include <string.h> // 加 double fun_add(double data_front, double data_back) { return da
阅读全文
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct Interface_t { /*初始化外设USB、SPI、IIC等*/ void (*init_peripheral)(void *obj); /*初始
阅读全文
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> // 定义抽象接口 typedef struct interface_t { struct interface_t *(*clone)(void *obj); void (*set)
阅读全文
摘要:#include <stdio.h> #include <assert.h> #include <stdlib.h> typedef struct _singleton_t { int data; }singleton_t; /* 全局静态指针(指向唯一实例) */ static singleton
阅读全文
摘要:C版本 工厂模式的实现步骤如下: 定义一个抽象产品接口,用于定义一组产品的通用行为。 定义一个具体产品类,实现抽象产品接口,用于提供具体的产品实现。 定义一个抽象工厂接口,用于定义工厂类应该实现的方法。 定义一个具体工厂类,实现抽象工厂接口,用于创建具体的产品对象。 在客户端代码中使用工厂类创建具体
阅读全文
摘要:资料链接 (【资料合集】设计模式的C语言应用——共十章)[https://bbs.huaweicloud.com/blogs/113179] (C语言状态机模块实现)[https://blog.csdn.net/xinghuanmeiying/article/details/89387451]
阅读全文
摘要:1 代码 1.1 Makefile Code TARGET = pointer CC=gcc DIR = $(shell pwd) DIR_OBJ = $(DIR)/obj DIR_SRC = $(DIR)/src DIR_INC = $(DIR)/inc SRC = $(wildcard $(DI
阅读全文
摘要:Makefile Code TARGET = factory CC=g++ DIR = $(shell pwd) DIR_OBJ = $(DIR)/obj DIR_SRC = $(DIR)/src DIR_INC = $(DIR)/inc SRC = $(wildcard $(DIR_SRC)/*.
阅读全文
摘要:C语言设计模式 1.工厂模式 C++设计模式 1.工厂模式 参考链接 【C语言实现设计模式】https://zhuanlan.zhihu.com/p/392882378 【设计模式】https://www.runoob.com/design-pattern/design-pattern-tutori
阅读全文