摘要: 单例模式分为饿汉式和懒汉式 饿汉式实现比较简单 //饿汉式class SingleTon1{ private static SingleTon1 instance=new SingleTon1(); private SingleTon1(){} public static SingleTon1 ge 阅读全文
posted @ 2024-03-25 18:50 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<string> #include<list> using namespace std; //一般情况下 用继承实现类的功能拓展 装饰模式 可以动态给一个类增加功能 //抽象英雄 class AbstractHero { public: virt 阅读全文
posted @ 2024-03-25 17:59 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class TV { public: void open() { cout << "打开电视" << endl; } void off() { cout << "关闭电视" << endl; } }; class Lig 阅读全文
posted @ 2024-03-25 17:59 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<vector> #include<algorithm> using namespace std; struct MyPrint { void operator()(int v1,int v2){ cout << v1 + v2 << endl; 阅读全文
posted @ 2024-03-25 17:55 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class DrinkTemplate { public: virtual void BoilWater() = 0;//煮开水 virtual void Brew() = 0;//冲泡 virtual void Pou 阅读全文
posted @ 2024-03-25 17:54 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<queue> using namespace std; class HandleClientProtocol { public: //处理金币 void AddMoney() { cout << "增加金币" << endl; } //增加砖石 阅读全文
posted @ 2024-03-25 17:54 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<stdlib.h> #include<stdio.h> #include<string.h> using namespace std; ////初始化 typedef void(*init_CSocketProtocol)(void** han 阅读全文
posted @ 2024-03-25 17:53 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<string> using namespace std; class AbstractFruit { public: virtual void showname() = 0; }; class Apple :public AbstractFru 阅读全文
posted @ 2024-03-25 17:53 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<string> #include<list> using namespace std; class AbstractHero { public: virtual void Update() = 0; }; class HeroA :public 阅读全文
posted @ 2024-03-25 17:52 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<vector> #include<algorithm> using namespace std; //水果基类 class AstractFruit { public: virtual void showname() = 0; }; class 阅读全文
posted @ 2024-03-25 17:51 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<vector> #include<queue> using namespace std; //二叉树节点的定义 struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNo 阅读全文
posted @ 2024-03-25 17:50 dmfsimle 阅读(1) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //单例 class SingleTon { public: static SingleTon* getinstance() { if (instance == nullptr)instance = new Single 阅读全文
posted @ 2024-03-25 17:50 dmfsimle 阅读(0) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<string> using namespace std; class AbstractCommonInterface { public: virtual void run() = 0; }; class MySystem :public Abs 阅读全文
posted @ 2024-03-25 17:49 dmfsimle 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //武器策略 class WeaponStrategy { public: virtual void UseWeapon() = 0; }; //匕首策略 class KnifeStrategy :public Weap 阅读全文
posted @ 2024-03-25 17:48 dmfsimle 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //苹果抽象类 class AbstractApple { public: virtual void ShowName() = 0; }; //中国苹果 class ChinaApple :public Abstract 阅读全文
posted @ 2024-03-25 17:48 dmfsimle 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public class MyQueue { private int[] array; private int front; private int rear; public MyQueue(int capacity){ this.array=new int[capacity]; } public 阅读全文
posted @ 2024-03-25 17:42 dmfsimle 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1 class Node{ 2 int data; 3 Node next; 4 Node(int data){ 5 this.data=data; 6 } 7 } 8 public class MyNodes { 9 private Node head; 10 private Node last; 阅读全文
posted @ 2024-03-25 17:42 dmfsimle 阅读(3) 评论(0) 推荐(0) 编辑
摘要: public class MyArray { private int[] array; private int size; public MyArray(int capacity){ this.array=new int[capacity]; size=0; } public void insert 阅读全文
posted @ 2024-03-25 17:40 dmfsimle 阅读(2) 评论(0) 推荐(0) 编辑