From ea3ffad91611c90fe7e6b0f1654ed6b2cad97422 Mon Sep 17 00:00:00 2001 From: ichdream Date: Mon, 30 Aug 2021 21:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86fileencoding=E6=94=B9=E4=B8=BAutf-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01.SimpleFactory/2.Code/SimpleFactory.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/01.SimpleFactory/2.Code/SimpleFactory.h b/01.SimpleFactory/2.Code/SimpleFactory.h index 94b7aa8..26c8969 100644 --- a/01.SimpleFactory/2.Code/SimpleFactory.h +++ b/01.SimpleFactory/2.Code/SimpleFactory.h @@ -5,20 +5,22 @@ #include using namespace std; -//抽象产品类AbstractProduct +//鎶借薄浜у搧绫籄bstractProduct class AbstractSportProduct { public: AbstractSportProduct(){ } - virtual ~AbstractSportProduct(){} - //抽象方法: - virtual void printName(){}; - virtual void play(){}; + virtual ~AbstractSportProduct(){}; + //鎶借薄鏂规硶锛 + // virtual void printName(){}; + virtual void printName() = 0; + // virtual void play(){}; + virtual void play() = 0; }; -//具体产品类Basketball +//鍏蜂綋浜у搧绫籅asketball class Basketball :public AbstractSportProduct { public: @@ -30,7 +32,7 @@ public: { } - //具体实现方法 + //鍏蜂綋瀹炵幇鏂规硶 void printName(){ printf("Jungle get Basketball\n"); } @@ -39,7 +41,7 @@ public: } }; -//具体产品类Football +//鍏蜂綋浜у搧绫籉ootball class Football :public AbstractSportProduct { public: @@ -51,7 +53,7 @@ public: { } - //具体实现方法 + //鍏蜂綋瀹炵幇鏂规硶 void printName(){ printf("Jungle get Football\n"); } @@ -60,7 +62,7 @@ public: } }; -//具体产品类Volleyball +//鍏蜂綋浜у搧绫籚olleyball class Volleyball :public AbstractSportProduct { public: @@ -72,7 +74,7 @@ public: { } - //具体实现方法 + //鍏蜂綋瀹炵幇鏂规硶 void printName(){ printf("Jungle get Volleyball\n"); }