我正在阅读来自http://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Design_Patterns#Creational_Patterns链接的构建器模式,下面的代码似乎使用类似于 pimpl idiom 的想法,有一个指向 PizzaBuilder 的指针在 Class Cook 中作为私人成员。皮条客惯用语及其在设计师模式中的使用方式之间是否有任何重叠?
class Cook
{
public:
void setPizzaBuilder(PizzaBuilder* pb)
{
m_pizzaBuilder = pb;
}
Pizza* getPizza()
{
return m_pizzaBuilder->getPizza();
}
void constructPizza()
{
m_pizzaBuilder->createNewPizzaProduct();
m_pizzaBuilder->buildDough();
m_pizzaBuilder->buildSauce();
m_pizzaBuilder->buildTopping();
}
private:
PizzaBuilder* m_pizzaBuilder;
};