Assume that we have the following category hierarchies:
class base. .}} Category Derived1: Public Base {...}; Category Derived2: Public Base {...}; Looking at the base *
which can indicate the Derived1
or Derived2
object how can I I can do a copy of the real object that this concrete type is unknown. I had thought about defining the copy constructor, but I do not think it is possible without the actual type involved. The only solution is to define a clone ()
method on each type of hierarchy. Does anyone feel more elegant?
Unfortunately, a virtual clone / duplication pattern is your only real choice
in it There are differences, but essentially they all come down to write down each type of work which can return a new copy.
Comments
Post a Comment