我试图理解原型设计模式。 参考:https://refactoring.guru/design-patterns/prototype/cpp/example
我看到了
的使用Prototype *Clone() const override {
return new ConcretePrototype1(*this);
}
new ConcretePrototype1(*this) 中的 *this 在 C++ 中到底是做什么/意味着什么?
另外,在原型设计模式中,客户端是否返回一个新对象?还是对原始对象的引用和调用函数仅使用原始对象中的函数/方法?
最后,如果返回相同的对象,那么 Singleton 和 Prototype 模式有什么区别?