[fpc-pascal] Arrays of objects

Joao Morais post at joaomorais.com.br
Wed Oct 31 12:39:55 CET 2007


Marco van de Voort wrote:
>> Adrian Maier wrote:
>>    VArray: array of TSomeClass;
>> begin
>>    SetLength(VArray, 10);
>>    // now you have VArray[0] .. VArray[9];
>>    SetLength(VArray, 20);
>>    // now you have [0] .. [19];
>>    // Length(VArray) = 20
>>    // for I := 0 to Pred(Length(VArray)) is a valid statement
>>
>> They are reference counted, just like ansi strings, ie don't worry about 
>> memory leakages.
> 
> ... Of the array itself. The objects it contains is another matter.

Ah, yes, forgot to mention this. I usually use dyn arrays to manage 
objects owned by other lists or objects.

--
Joao Morais



More information about the fpc-pascal mailing list