[fpc-pascal] Arrays of objects

Adrian Maier adrian.maier at gmail.com
Wed Oct 31 09:23:19 CET 2007


Hello,

I'm seeking for advice about which is the best way to hold an array of
class instances
I need to access the elements using its position (like a regular
array) , and also i'd like
the structure to grow when I add more elements.

Fpc has  'dynamic arrays'  ,  and also there several classes like
TFPList,  TList
in RTL.Classes  . Also,  the FCL has the  contrns  unit which also contains
some classes that can be used for storing objects into memory.

At this point there are already too many options,  and I am unsure what to use.

The 'dynamic arrays'  are very close to what i'm looking for,  except
that I couldn't
find the documentation page of the SetLength procedure. In particular : what
happens if i call this procedure again for the same array  :  an does
it "re-allocate"
memory for the array  , or "resizes" its memory ?



Cheers,
Adrian Maier



More information about the fpc-pascal mailing list