adjust format
parent
687fcf5cb6
commit
875e2b2bfc
|
@ -39,7 +39,7 @@ public:
|
|||
AbstractSportProduct(){
|
||||
|
||||
}
|
||||
virtual ~AbstractSportProduct(){}
|
||||
virtual ~AbstractSportProduct(){}
|
||||
//抽象方法:
|
||||
virtual void printName() = 0;
|
||||
virtual void play(){} = 0;
|
||||
|
@ -107,7 +107,7 @@ class AbstractFactory
|
|||
{
|
||||
public:
|
||||
virtual AbstractSportProduct *getSportProduct() = 0;
|
||||
virtual ~AbstractFactory(){}
|
||||
virtual ~AbstractFactory(){}
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -166,24 +166,24 @@ int main()
|
|||
|
||||
fac = new BasketballFactory();
|
||||
product = fac->getSportProduct();
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
|
||||
fac = new FootballFactory();
|
||||
product = fac->getSportProduct();
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
|
||||
fac = new VolleyballFactory();
|
||||
product = fac->getSportProduct();
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
delete fac;
|
||||
fac = nullptr;
|
||||
delete product;
|
||||
product = nullptr;
|
||||
|
||||
system("pause");
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue