What is the difference between two arrays definitions? Are they realized different in memory?
int var = 5;
int (*p4)[2] = new int [var][2]; // first 2d array
int** p5 = new int*[var]; // second 2d array
for(int i = 0; i < var; ++i){
p5[i] = new int[2];
}
Yes, they’re very different. The first is really a single array; the second is actually
var+1arrays, potentially scattered all over your RAM.vararrays hold the data, and one holds pointers to thevardata arrays.