Question about Types and Fields

BlitzMax Forums/BlitzMax Beginners Area/Question about Types and Fields

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The line:

Honda_2 = Honda_1

does *NOT* copy the value "red" from car 1 to car 2.

What it does it make the variable `Honda_2` point to the same car that the variable `Honda_1` points to. They are both looking at the same car. Whatever color you then set car 1 to, both variables will be looking at. You think you have two separate cars. You DID have two separate cars after the "Honda_2:Car=New Car" line, but then you made the POINTER TO the second car be the same as the POINTER TO the first car. Changing the pointer doesn't change the content of the fields, and it doesn't copy them. You can have more than one variable pointing to the same instance of the type.

If you want to make the CONTENT of Car 2 be the same as the CONTENT of Car 1, you do:

Honda_2.Color=Honda_1.Color