Best method to implement an abstract factory pattern

前端 未结 2 1900
醉酒成梦
醉酒成梦 2021-01-20 05:15

Consider following code:

#include 


// =============================


class Shape{
public:
    virtual ~Shape(){};

    virtual void process         


        
2条回答
  •  既然无缘
    2021-01-20 06:01

    Your factories are passing around ownership. There's another alternative to that aspect; instead of passing around ownership, you can make the factory own the objects:

       class Factory {
       public:
          ~Factory() { for(int i=0;i vec;
       };
    

提交回复
热议问题