Creating copy of object?

jrvbdeveloper

Member
Joined
Jul 15, 2007
Messages
17
Programming Experience
Beginner
Hi,

In my code, I was basically assigning 1 object (self-created) to another. For example,
car1 As Car
car2 As Car
car2 = car1

I realize that both car1 and car2 are supposed to be referencing the same object. However, when I change a paremeter of one of the objects, the other does not change, so I am confused. I *do not* want the other object to change, so can I leave my code as is? Or do I need to create a clone method, but why isn't this causing me problems?
 
There is no indication of instances of 'car' in your post. Also what is 'car', a class? a structure?
 
Both variable car1 and car2 reference the same instance in this case, changes brought through both variables will change the same car instance.
 
Back
Top