fix some code bug

master
FengJungle 2021-10-29 21:33:26 +08:00
parent d4d7abc3ec
commit 0ecf749949
5 changed files with 12 additions and 6 deletions

View File

@ -22,7 +22,7 @@ class GameA:public Game
public: public:
GameA(){} GameA(){}
void play(){ void play(){
printf("Jungle<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϷA\n"); printf("Jungle玩游戏A\n");
} }
}; };
@ -32,7 +32,7 @@ class GameB :public Game
public: public:
GameB(){} GameB(){}
void play(){ void play(){
printf("Jungle<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϷB\n"); printf("Jungle玩游戏B\n");
} }
}; };

View File

@ -16,7 +16,7 @@ class Phone :public Component
public: public:
Phone(){} Phone(){}
void operation(){ void operation(){
printf("<EFBFBD>ֻ<EFBFBD>\n"); printf("手机\n");
} }
}; };

View File

@ -47,6 +47,8 @@ public:
realSubject = new RealSubject(); realSubject = new RealSubject();
log = new Log(); log = new Log();
} }
Proxy(const Proxy& o) = delete;
Proxy& operator=(const Proxy&) = delete;
~Proxy(){ ~Proxy(){
delete realSubject; delete realSubject;
delete log; delete log;

View File

@ -72,6 +72,8 @@ public:
printf("开关控制电灯\n"); printf("开关控制电灯\n");
lamp = new Lamp(); lamp = new Lamp();
} }
LampCommand(const LampCommand&) = delete;
LampCommand& operator=(const LampCommand&) = delete;
~LampCommand(){ ~LampCommand(){
delete lamp; delete lamp;
lamp = nullptr; lamp = nullptr;
@ -97,9 +99,11 @@ public:
printf("开关控制风扇\n"); printf("开关控制风扇\n");
fan = new Fan(); fan = new Fan();
} }
FanCommand(const FanCommand& a) = delete;
FanCommand& operator=(const FanCommand&) = delete;
~FanCommand(){ ~FanCommand(){
delete lamp; delete fan;
lamp = nullptr; fan = nullptr;
} }
// 实现execute() // 实现execute()
void execute(){ void execute(){

View File

@ -21,7 +21,7 @@ int main()
printf("\n\n"); printf("\n\n");
// 逆序遍历 // 逆序遍历
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n"); printf("逆序遍历:\n");
remoteControl->last(); remoteControl->last();
// 遍历电视所有频道 // 遍历电视所有频道
while (remoteControl->hasPrevious()){ while (remoteControl->hasPrevious()){