DesignPattern/01.SimpleFactory/2.Code/main.cpp

30 lines
476 B
C++
Raw Normal View History

2019-10-17 13:55:01 +00:00
#include <iostream>
#include "SimpleFactory.h"
int main()
{
printf("<EFBFBD>򵥹<EFBFBD><EFBFBD><EFBFBD>ģʽ\n");
//<2F><><EFBFBD><EFBFBD><E5B9A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Factory *fac = new Factory();
AbstractSportProduct *product = NULL;
product = fac->getSportProduct("Basketball");
2020-11-29 07:28:46 +00:00
if (product) {
delete product;
}
2019-10-17 13:55:01 +00:00
product = fac->getSportProduct("Football");
2020-11-29 07:28:46 +00:00
if (product) {
delete product;
}
2019-10-17 13:55:01 +00:00
product = fac->getSportProduct("Volleyball");
2020-11-29 07:28:46 +00:00
if (product) {
delete product;
}
2019-10-17 13:55:01 +00:00
2020-11-29 07:28:46 +00:00
delete fac;
2019-10-17 13:55:01 +00:00
system("pause");
return 0;
}