"header" is an object of a struct and you can consider header.img to have a value of 496. And header struct has 3 integer elements so is the value 12 bytes. (Considering 4 bytes a int)
double** MatrixBuffers = new double* [header.img];
MatrixBuffers[0] = new double[header.img* 12];
for (unsigned int i=1; i<header.img; ++i) {
MatrixBuffers[i] = MatrixBuffers[0] + i * 12;
}
globaldata.adv_MatrixBuffers = MatrixBuffers;
I understand that MatrixBuffers is a pointer to 496 doubles. But I don't understand what's happening in the second line.
MatrixBuffers[0] = new double[header.img* 12];
1.Does this mean MatrixBuffers[0] is a pointer to 496*12 doubles ? 2.What is happening in the for loop ? 3.Later in the code, MatrixBuffer[0] is being passed to a function. Does this mean I am passing a pointer that is the base address to MatrixBuffers[0] ?