DesignPattern/04.BuilderPattern/2.Code/main.cpp

31 lines
568 B
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "BuilderPattern.h"
int main()
{
// 抽象建造者
AbstractBuilder *builder;
// 指挥者
Director *director = new Director();
// 产品House
House *house;
// 指定具体建造者A
builder = new ConcreteBuilderA();
director->setBuilder(builder);
house = director->construct();
house->printfHouseInfo();
delete builder;
// 指定具体建造者A
builder = new ConcreteBuilderB();
director->setBuilder(builder);
house = director->construct();
house->printfHouseInfo();
system("pause");
delete director;
delete builder;
return 0;
}