From d4d7abc3ec1dd0f2fbea982022e7b9f182282786 Mon Sep 17 00:00:00 2001 From: FengJungle Date: Fri, 29 Oct 2021 21:20:50 +0800 Subject: [PATCH] delete copy ctor and copy assgin for BuilderPattern --- 04.BuilderPattern/2.Code/BuilderPattern.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/04.BuilderPattern/2.Code/BuilderPattern.h b/04.BuilderPattern/2.Code/BuilderPattern.h index 4e90b1c..bb4452c 100644 --- a/04.BuilderPattern/2.Code/BuilderPattern.h +++ b/04.BuilderPattern/2.Code/BuilderPattern.h @@ -38,6 +38,8 @@ public: AbstractBuilder() { house = new House(); } + AbstractBuilder(const AbstractBuilder& o) = delete; + AbstractBuilder& operator=(const AbstractBuilder& o) = delete; virtual ~AbstractBuilder() { if (house != nullptr) @@ -62,6 +64,8 @@ public: ConcreteBuilderA() { printf("ConcreteBuilderA\n"); } + ConcreteBuilderA(const ConcreteBuilderA& o) = delete; + ConcreteBuilderA& operator=(const ConcreteBuilderA& o) = delete; ~ConcreteBuilderA() { if (this->house != nullptr) @@ -92,7 +96,9 @@ public: ConcreteBuilderB() { printf("ConcreteBuilderB\n"); } - ~ConcreteBuilderA() + ConcreteBuilderB(const ConcreteBuilderB&) = delete; + ConcreteBuilderB& operator=(const ConcreteBuilderB&) = delete; + ~ConcreteBuilderB() { if (this->house != nullptr) {