From ad8fb8e31c42c198b79b3f4df1901d19fa84892c Mon Sep 17 00:00:00 2001 From: Qiangguo Feng <32355651+FengJungle@users.noreply.github.com> Date: Tue, 19 Oct 2021 18:22:17 +0800 Subject: [PATCH] bugfix: delete copy ctr and operator= --- 11.FacadePattern/2.Code/FacadePattern.h | 37 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/11.FacadePattern/2.Code/FacadePattern.h b/11.FacadePattern/2.Code/FacadePattern.h index 4382b78..9fb6322 100644 --- a/11.FacadePattern/2.Code/FacadePattern.h +++ b/11.FacadePattern/2.Code/FacadePattern.h @@ -1,47 +1,48 @@ #ifndef __FACADE_PATTERN_H__ #define __FACADE_PATTERN_H__ -//×Óϵͳ£ºÄÚ´æ +#include + +// subsystem: Memory class Memory { public: Memory(){} void selfCheck(){ - printf("¡­¡­¡­¡­ÄÚ´æ×Լ졭¡­\n"); + printf("memory selfchecking......\n"); } }; -//×Óϵͳ£ºCPU +// subsystem: CPU class CPU { public: CPU(){} void run(){ - printf("¡­¡­¡­¡­ÔËÐÐCPUÔËÐС­¡­\n"); + printf("running cpu......\n"); } }; -//×Óϵͳ£ºÓ²ÅÌ +// subsystem: hardDisk class HardDisk { public: HardDisk(){} void read(){ - printf("¡­¡­¡­¡­¶ÁÈ¡Ó²ÅÌ¡­¡­\n"); + printf("reading hardDisk......\n"); } }; -//×Óϵͳ£º²Ù×÷ϵͳ +// subsystem: OS class OS { public: OS(){} void load(){ - printf("¡­¡­¡­¡­ÔØÈë²Ù×÷ϵͳ¡­¡­\n"); + printf("loading os.....\n"); } }; -//Íâ¹ÛÀà class Facade { public: @@ -51,13 +52,25 @@ public: hardDisk = new HardDisk(); os = new OS(); } + ~Facade(){ + delete memory; + delete cpu; + delete hardDisk; + delete os; + memory = nullptr; + cpu = nullptr; + hardDisk = nullptr; + os = nullptr; + } + Facade(const Facade& facade) = delete; + Facade operator=(const Facade& facade) = delete; void powerOn(){ - printf("ÕýÔÚ¿ª»ú¡­¡­\n"); + printf("power on……\n"); memory->selfCheck(); cpu->run(); hardDisk->read(); os->load(); - printf("¿ª»úÍê³É£¡\n"); + printf("ready!\n"); } private: Memory *memory; @@ -66,4 +79,4 @@ private: OS *os; }; -#endif //__FACADE_PATTERN_H__ \ No newline at end of file +#endif //__FACADE_PATTERN_H__