Design/factoryMethod/main.cpp

21 lines
561 B
C++
Raw Normal View History

2024-10-28 14:07:29 +08:00
/*
* @Description:
* @version:
* @Author:
* @Date: 2023-10-08 14:47:54
* @LastEditors:
* @LastEditTime: 2023-10-08 14:54:44
*/
#include "FactoryMethod.hpp"
int main() {
std::shared_ptr<AbstractFactory> factory = nullptr;
std::shared_ptr<AbstractProduct> product = nullptr;
factory = std::make_shared<MachineryFactory>();
product = factory->getProduct();
factory = std::make_shared<MagicFactory>();
product = factory->getProduct();
factory = std::make_shared<Greenfactory>();
product = factory->getProduct();
return 0;
}