In C/C++, we can define multidimensional arrays in simple words as array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order). A dynamic 2D array is basically an array of pointers to arrays. So you first need to initialize the array of pointers to pointers and then initialize each 1d array in a loop. Example below using new
:
#include <iostream>
int main()
{
int row = 3, col =3;
array = (int**) new int* [row];
for (int i = 0; i < row; i++) array[i] = new int[col];
for (int i = 0; i < row; i++)