C++ Memory allocation. Matrix
问题 I looked into two different method to allocate memory for the elements of a matrix Method n.1 int** matrix = new int*[rows]; for (int i = 0; i < rows; ++i) matrix[i] = new int[cols]; Method n.2 int** matrix = new int*[rows]; if (rows) { matrix[0] = new int[rows * cols]; for (int i = 1; i < rows; ++i) matrix[i] = matrix[0] + i * cols; } I can figure out what Method n.1 does, but I can't figure out what exactly is supposed to do the if clause in Method n.2 (I would implement it without and it