开发者

Is there a pattern name for a factory method that returns another instance of the interface's class?

开发者 https://www.devze.com 2023-02-12 14:16 出处:网络
Is there a design pattern or idiom for a factory method on an interface that returns a new instance of the same interface? For example, in C++ it might look like:

Is there a design pattern or idiom for a factory method on an interface that returns a new instance of the same interface? For example, in C++ it might look like:

class IFoo
{
  public:
    virtual std::auto_ptr<IFoo> Operation();
};

Where the Operation method for som开发者_C百科e concrete subclass of IFoo creates and returns a new instance of a (potentially different) concrete subclass of IFoo.

0

精彩评论

暂无评论...
验证码 换一张
取 消