Array indices

Top  Previous  Next

What is translated > Types > Arrays > Array indices

 

While in Delphi the lower bound and the upper bound of a static array have to be defined, in C++ arrays are always zero based, i.e. the undermost index is 0 and the topmost index is the size of the array minus 1.

 

If the lower bound of an array isn't null, Delphi2Cpp corrects an index by which the array is accessed automatically by subtraction of the lower bound.

Example:

 

var 

arr : array [1..3] of integer;

i : integer;

begin

  for i := low(arr) to high(arr) do 

   arr[i] := 0;

end;

 

is translated to:

 

int arr [ 3 ];

int i;

for ( i = 1; i <= 3; i++)

  arr[i - 1] = 0;

 

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content