runtime allocation of array (C++, FMX)

  

i need an array at runtime to hold some x-y coordinate data. It may be anywhere from a few dozen points to several thousands. So, to be efficient i’d like to allocate the array at runtime. I found an example but i can’t extend it. Here is what i have now:

double *A;
A = new double[NumSamp]; // NumSamp is an int set in earlier code at runtime
for (int y = 1; y < NumSamp ; y++) {
A[y] = y;
}
delete [] A;
A = NULL;

This code works fine, but when i try to change to two dimensions i get E2034 Cannot convert double( *)[2] to double*. Here is the line i changed that caused the error:

A = new double[NumSamp][2];

How should i be doing this? I’m working in C++Builder (10.3.1) and will target Win32, iOS, and Android.

Comments are closed.