[fpc-pascal] Problems with assigning pointers
Jürgen Hestermann
juergen.hestermann at gmx.de
Tue Apr 10 19:09:28 CEST 2012
dhkblaszyk at zeelandnet.nl schrieb:
> edge_list[edge_count - 1].v1 := v1; //<---- after this line the
value of v1^.x suddenly is changed!!??!!
Could it be that you do something else with "edge_list" before the
assignment?
Keep in mind that "edge_list" is a dynamic array and therefore a pointer
(with
automatic dereferencing by the square brackets).
If you somehow changed this pointer (without realizing it) it could be
that the
assignment overwrites v1 (or the data it points to).
But pointer are always a source of errors.
Only use them when it's unavoidable.
If you can do the same without pointers then don't use them. ;-)
More information about the fpc-pascal
mailing list