Making a copy of an object?
Blitz3D Forums/Blitz3D Beginners Area/Making a copy of an object?
| ||
What's the simplest way to make an exact copy of an existing object? If p is an object of type Person, how do I make q an object of type person with all the same values, but independent (so that changing p\x doesn't change q\x)? Or is the fastest way q\x = p\x, q\y = p\y etc? Cheers. |
| ||
Yes, the only way that I know of is simply creating another instance and copying the fields over one by one, perhaps in a function. There are many times I wish I had use of a copy constructor (not to mention operator overloading)... =) <EDIT> ... and then I kick myself because Blitz is such a nice language and sticking in operator overloading would probably obfuscate it terribly... but I still like the idea of a copy constructor. =) |