Re: Array pointers like C++



Thanks, that was helpful.

Why is it that the C++
double *l = someArray[a][b];
translates to
l := @SomeArray[A,B,0];
and not
l := @SomeArray[A,B];

I realize that the first index of the array we want the address of, has the
same address as the array itself, but why are we referring to the first
index instead of the array? I this a limitation of Object Pascal?

Bjorn

"Jamie" <jamie_5_not_valid_after_5_Please@xxxxxxxxxxx> wrote in message
news:noOce.6320$cZ6.1459@xxxxxxxxxxx
> news.online.no wrote:
>
>> Hi,
>>
>> I am struggling with translating some code from C++ to Delphi.
>>
>> Consider this C++ code:
>>
>> class var:
>> double someArray[2][4][6];
>>
>> local method vars:
>> int a, b, c, d, e;
>> ... // vars initialized
>> double *l = someArray[a][b];
>> double p = l[c] = (double) d/e;
>> l[0] = p;
>>
>> What is actualy happening here? is someArray changed in the local method?
>> How can I do this in Delphi, or Object Pascal in general?
>>
>> Bjorn
> Var
> SomeArray:Array[0..1,0..3,0..5] of double; // or
> Array[0..1][0..3][0..5]of double
>
> a,b,c,d,e:integer;
> l :PdoubleArray;
> P :Double;
> Begin
> // initiate your Variables.
> l := @SomeArray[A,B,0]; // use zero in un specified indexes.
> P := l[c];
> l[o] := p;
>
> P.S.
> in case for some reason you don't have that TdoubleArray in the
> sysUtils file just create the type your self..
> type
> PDoubelArray = ^TDoubleArray;
> TDoubleArray = Array[0..32768] of Double;
>


.



Relevant Pages

  • Re: array lines shifting
    ... Ronen Kfir wrote: ... > how much will the lines in array move towards upwards. ... You use the first index for the columns and the second index ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [PHP] mysql_fetch_array
    ... also, if you read the first line just above the first example of use, you will notice that it says that reset will return the first array element or false. ... The reason that you are getting the first column is because in your reset call, you are referencing the first index entry in your array. ... $fotos contains all records found in a db table, the SELECT statement is retrieving 2 columns from a table, how do I store all records in a 2 dimention table so I can use it later? ...
    (php.general)
  • Re: Array pointers like C++
    ... I realize that the first index of the array we want the address of, has the same address as the array itself, but why are we referring to the first index instead of the array? ... returns a pointer to a multiple dim array. ... its the same as if you don't specify any index of some kind of ...
    (comp.lang.pascal.delphi.misc)
  • Re: Q on the Array function...
    ... But I also go further back in history, to Fortran, before ... array as dimensionin that ancient tongue, it meant ... that its first index had 7 elements and its second index 2: ... course you were also defining its upper bound, ...
    (comp.databases.ms-access)
  • Re: TrySetLength not possible !? :(
    ... The length of the array is supposed to be the number of elements. ... function SkybuckTrySetLength(var ParaVar; const ParaNewLength: ... vWord: array of Word; ... vLongword: array of Longword; ...
    (alt.comp.lang.borland-delphi)