I had a problem creating my 2D C ++ dynamic array. I want it to have a dynamic number (like numR) of "rows" and a fixed (like 2) number of "columns".
I tried to do it like this:
const numC = 2;
int numR;
numR = 10;
double *myArray[numC];
myArray = new double[numR];
Unfortunately, it does not work. Can this be done in this way?
Of course, I could use double **myArrayand initialize it as if both dimensions were dynamic (using numC as a limiter in the loop), but I would like to avoid it if possible.
Thanks in advance.
source
share