Hi there,
Here's a pretty basic question about objects for the OO types out there:
How do I copy an object to another object?
For example, I'd like to copy object A to object B, but still maintain them as separate data.
As I understand it, when I do this with the two objects:
B = A
...B now points to the same object as A (i.e. they're both references to the same data instance).
What I want is to *copy* A to B, then be able to change B without affecting A - like what would happen if I was dealing with primitive variables.
Is there an easy way to do this, or do I have to write a copy function for each type of object I'm working with?
Thanks for any help!
Here's a pretty basic question about objects for the OO types out there:
How do I copy an object to another object?
For example, I'd like to copy object A to object B, but still maintain them as separate data.
As I understand it, when I do this with the two objects:
B = A
...B now points to the same object as A (i.e. they're both references to the same data instance).
What I want is to *copy* A to B, then be able to change B without affecting A - like what would happen if I was dealing with primitive variables.
Is there an easy way to do this, or do I have to write a copy function for each type of object I'm working with?
Thanks for any help!