"Prototype pattern" 和 "Virtual constructor" 是相同的模式吗?
Are the "Prototype pattern" and the "Virtual constructor" the same patterns?
虚拟构造函数 - 实现 virtual function clone()
:
class X {
public:
virtual X* clone() {
return new X(*this);
}
};
是指与原型设计模式相同的概念吗?
... mean the same concept as the Prototype design pattern?
不,不是。 可克隆接口只是Prototype Design Pattern.
实现的一部分
Prototype 的要点是有一个 Factory 来保存原型实例的实例,并且知道将哪个用作克隆源来创建新实例。
虚拟构造函数 - 实现 virtual function clone()
:
class X {
public:
virtual X* clone() {
return new X(*this);
}
};
是指与原型设计模式相同的概念吗?
... mean the same concept as the Prototype design pattern?
不,不是。 可克隆接口只是Prototype Design Pattern.
实现的一部分Prototype 的要点是有一个 Factory 来保存原型实例的实例,并且知道将哪个用作克隆源来创建新实例。