posted 21 years ago
I wrote a small program that reads in integer values from a comma-dilimited file. What's strange is that depending where I place a local integer array, the output changes. Here is the code ...
Now, if I uncomment the line that says "// BAD" and comment the line that says "// GOOD", the data stored in the Vector is always the same for each element.
IOW, if the first line read is "1,2,3,4,5" and the second line read is "6,7,8,9,0", executing the original code will produce a Vector with two Element objects: the first (0-index) Element object will have the integer data {1,2,3,4,5} and the second (1-index) Element object will have the integer data {6,7,8,9,0}. However, if I change the code as described in the previous paragraph, the first Element object will have the integer data {6,7,8,9,0} and the second Element object will have the integer data {6,7,8,9,0}.
Anyone know why?