Re: Array pointers like C++
- From: "Bjorn Antonsen" <bjornan@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 20:46:34 +0200
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;
>
.
- References:
- Array pointers like C++
- From: news.online.no
- Re: Array pointers like C++
- From: Jamie
- Array pointers like C++
- Prev by Date: Re: Assigning Variables at runtime?
- Next by Date: Re: Assigning Variables at runtime?
- Previous by thread: Re: Array pointers like C++
- Next by thread: Help: Delphi7.1 for Windows Server2003 Std Edition
- Index(es):
Relevant Pages
|