Does the Virtual constructor - implementing virtual function clone():
class X {
public:
virtual X* clone() {
return new X(*this);
}
};
mean the same concept as the Prototype design pattern?
Does the Virtual constructor - implementing virtual function clone():
class X {
public:
virtual X* clone() {
return new X(*this);
}
};
mean the same concept as the Prototype design pattern?
Copyright © 2021 Jogjafile Inc.
No, it doesn't. The cloneable interface is only part of the implementation of the Prototype Design Pattern.
The point of Prototype is to have a Factory to hold instances of prototypical instances, and knows which to use as cloning source to create new instances.