Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. Co-opt one instance of a class for use as a breeder of all future instances. The new Problem Application "hard wires" the class of object to create in each "new" expression. Discussion Declare an abstract base class that specifies a pure virtual "clone" method, and, maintains a dictionary of all "cloneable" concrete derived classes. Any class that needs a "polymorphic constructor" capability: derives itself from the abstract base class,
Read full article from Prototype Design Pattern
No comments:
Post a Comment