ben oliver wrote:what I want to do is -- First I need to put "order" object into map, then I need to retrieve it out and make some change and put it back using a different key.
But by doing this way, I think I am also altering the original "order" object
so next time when I do map.get("john") I would get a different object, which is NOT what I want.
I want to keep the value for key of "john", take it out, maybe create another duplicated one and change on that new one and put it into map with a new key.
but I just don't know how. Any help ?
ben oliver wrote:
1. I don't need to worry how complex the "LineItem" is and just need to do the above, correct ?
2. Does "order" object's "item" points to the same object "anotherOrder" object's "item" ? That scares me most.
ben oliver wrote:Thanks so much for the reply...
Dennis Deems wrote:For this use case I think a Factory makes better sense than a copy constructor. Use of a copy constructor really ought to be limited to cases in which we really do want an honest-to-goodness copy.
ben oliver wrote:I forgot to say " Thank you Jeff !"