khafan khafan - 1 year ago 229
C++ Question

C++ to Delphi pointer conversion

I am trying to convert an open source C++ project to Delphi(Berlin 10.1). it uses some pointers which i can not find a way to convert them to Delphi pointers. How can i translate this piece code from C++ to Delphi?
Here is the code:

double* ptr;

ptr = (double*)malloc(10*sizeof(double)+324);



int n;

double** Solution;

*Solution = ptr;

Answer Source
   TDoubleArray  = array[Word] of Double;
   PDoubleArray  = ^TDoubleArray;

ptr: PDoubleArray;

GetMem(ptr, 10*sizeof(double)+324);

ptr[10*n+1] := y*12;   

ptr[1] := n;

//here you have to check usage case
//probably you need 2D array
Solution: ^PDoubleArray;

Solution^ := ptr;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download