I have the following code which I got through one of the posts here
I wish to know how to traverse or loop through a dynamic 2D array using pointer to pointer as returned by the code above.Code:#ifndef TDYNAMICARRAY_H #define TDYNAMICARRAY_H namespace Massive { template<class T> T **AllocateDynamic2DArray(int nRows,int nCols) { T **dynamicArray; dynamicArray = new T*[nRows]; for(int i=0;i< nRows;i++) { dynamicArray[i] = new T[nCols]; } return dynamicArray; } template<class T> void FreeDynamic2DArray( T ** dArray) { delete [] *dArray; delete [] dArray; } } #endif
like I would in a static T[20][20] 2D array.


Reply With Quote
Bookmarks