Re: Array pointers like C++



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;

.