C++ new 二維陣列:
int m, n;
int i, j;
int **ptr;
cout<<"輸入Array維度:"<< endl;
cin>> m >> n;
ptr = new int*[m];
for(i = 0; i < m; i++)
*(ptr+i) = new int[n];
for(i = 0; i < m; i++)
for(j = 0; j < n; j++)
ptr[i][j] = i+j;
for(i = 0; i < m; i++) {
for(j = 0; j < n; j++)
cout << ptr[i][j] << " ";
cout << endl;
}
for(i = 0; i < m; i++)
delete [] (*(ptr+i));
delete [] ptr;