From 0ecf7499497d23ed0d13c546aea4944ef1714dd2 Mon Sep 17 00:00:00 2001 From: FengJungle Date: Fri, 29 Oct 2021 21:33:26 +0800 Subject: [PATCH] fix some code bug --- 08.BridgePattern/2.Code/BridgePattern.h | 4 ++-- 10.DecoratorPattern/2.Code/DecoratorPattern.h | 2 +- 13.ProxyPattern/2.Code/ProxyPattern.h | 2 ++ 15.CommandPattern/2.Code/CommandPattern.h | 8 ++++++-- 17.IteratorPattern/2.Code/main.cpp | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/08.BridgePattern/2.Code/BridgePattern.h b/08.BridgePattern/2.Code/BridgePattern.h index 37e3c2f..0269ae8 100644 --- a/08.BridgePattern/2.Code/BridgePattern.h +++ b/08.BridgePattern/2.Code/BridgePattern.h @@ -22,7 +22,7 @@ class GameA:public Game public: GameA(){} void play(){ - printf("Jungle����ϷA\n"); + printf("Jungle玩游戏A\n"); } }; @@ -32,7 +32,7 @@ class GameB :public Game public: GameB(){} void play(){ - printf("Jungle����ϷB\n"); + printf("Jungle玩游戏B\n"); } }; diff --git a/10.DecoratorPattern/2.Code/DecoratorPattern.h b/10.DecoratorPattern/2.Code/DecoratorPattern.h index 7ca69d4..81d82fa 100644 --- a/10.DecoratorPattern/2.Code/DecoratorPattern.h +++ b/10.DecoratorPattern/2.Code/DecoratorPattern.h @@ -16,7 +16,7 @@ class Phone :public Component public: Phone(){} void operation(){ - printf("�ֻ�\n"); + printf("手机\n"); } }; diff --git a/13.ProxyPattern/2.Code/ProxyPattern.h b/13.ProxyPattern/2.Code/ProxyPattern.h index 2fe4f06..5e13857 100644 --- a/13.ProxyPattern/2.Code/ProxyPattern.h +++ b/13.ProxyPattern/2.Code/ProxyPattern.h @@ -47,6 +47,8 @@ public: realSubject = new RealSubject(); log = new Log(); } + Proxy(const Proxy& o) = delete; + Proxy& operator=(const Proxy&) = delete; ~Proxy(){ delete realSubject; delete log; diff --git a/15.CommandPattern/2.Code/CommandPattern.h b/15.CommandPattern/2.Code/CommandPattern.h index dd13069..2e4078a 100644 --- a/15.CommandPattern/2.Code/CommandPattern.h +++ b/15.CommandPattern/2.Code/CommandPattern.h @@ -72,6 +72,8 @@ public: printf("开关控制电灯\n"); lamp = new Lamp(); } + LampCommand(const LampCommand&) = delete; + LampCommand& operator=(const LampCommand&) = delete; ~LampCommand(){ delete lamp; lamp = nullptr; @@ -97,9 +99,11 @@ public: printf("开关控制风扇\n"); fan = new Fan(); } + FanCommand(const FanCommand& a) = delete; + FanCommand& operator=(const FanCommand&) = delete; ~FanCommand(){ - delete lamp; - lamp = nullptr; + delete fan; + fan = nullptr; } // 实现execute() void execute(){ diff --git a/17.IteratorPattern/2.Code/main.cpp b/17.IteratorPattern/2.Code/main.cpp index 58674a2..c07a73f 100644 --- a/17.IteratorPattern/2.Code/main.cpp +++ b/17.IteratorPattern/2.Code/main.cpp @@ -21,7 +21,7 @@ int main() printf("\n\n"); // 逆序遍历 - printf("�������:\n"); + printf("逆序遍历:\n"); remoteControl->last(); // 遍历电视所有频道 while (remoteControl->hasPrevious()){