DesignPattern/02.FactoryMethod/2.Code/main.cpp

44 lines
624 B
C++
Raw Normal View History

2019-10-17 23:32:47 +00:00
#include <iostream>
#include "FactoryMethod.h"
int main()
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ\n");
//<2F><><EFBFBD><EFBFBD><E5B9A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AbstractFactory *fac = NULL;
AbstractSportProduct *product = NULL;
fac = new BasketballFactory();
product = fac->getSportProduct();
2020-11-29 07:28:46 +00:00
if (fac)
{
delete fac;
}
if (product) {
delete product;
}
2019-10-17 23:32:47 +00:00
fac = new FootballFactory();
product = fac->getSportProduct();
2020-11-29 07:28:46 +00:00
if (fac)
{
delete fac;
}
if (product) {
delete product;
}
2019-10-17 23:32:47 +00:00
fac = new VolleyballFactory();
product = fac->getSportProduct();
2020-11-29 07:28:46 +00:00
if (fac)
{
delete fac;
}
if (product) {
delete product;
}
2019-10-17 23:32:47 +00:00
system("pause");
return 0;
}