From 4138d7358c1bd2c8fc1acab10ca23c2b1a3d0615 Mon Sep 17 00:00:00 2001 From: modao <13556366913@163.com> Date: Tue, 30 Jul 2019 14:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86Builder=E7=B1=BB?= =?UTF-8?q?=E7=9A=84Product=E6=8C=87=E9=92=88=E4=B8=BAProduct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/Builder/Builder.cpp | 4 ++-- code/Builder/Builder.h | 2 +- code/Builder/ConcreteBuilder.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/Builder/Builder.cpp b/code/Builder/Builder.cpp index 36d5790..e7be04f 100644 --- a/code/Builder/Builder.cpp +++ b/code/Builder/Builder.cpp @@ -38,5 +38,5 @@ void Builder::buildPartC(){ Product* Builder::getResult(){ - return m_prod; -} \ No newline at end of file + return &m_prod; +} diff --git a/code/Builder/Builder.h b/code/Builder/Builder.h index d4519fb..c78af30 100644 --- a/code/Builder/Builder.h +++ b/code/Builder/Builder.h @@ -21,6 +21,6 @@ class Builder virtual void buildPartC(); virtual Product * getResult(); protected : - Product * m_prod; + Product m_prod; }; #endif // !defined(EA_938F1725_29F0_4174_93A3_D49DAB5D16A0__INCLUDED_) diff --git a/code/Builder/ConcreteBuilder.cpp b/code/Builder/ConcreteBuilder.cpp index c1adf72..76e42f2 100644 --- a/code/Builder/ConcreteBuilder.cpp +++ b/code/Builder/ConcreteBuilder.cpp @@ -19,15 +19,15 @@ ConcreteBuilder::~ConcreteBuilder(){ } void ConcreteBuilder::buildPartA(){ - m_prod->setA("A Style "); //不同的建造者,可以实现不同产品的建造 + m_prod.setA("A Style "); //不同的建造者,可以实现不同产品的建造 } void ConcreteBuilder::buildPartB(){ - m_prod->setB("B Style "); + m_prod.setB("B Style "); } void ConcreteBuilder::buildPartC(){ - m_prod->setC("C style "); -} \ No newline at end of file + m_prod.setC("C style "); +}