With respect to the following code snippet for making a dynamic array
开发者_C百科template <class Type>
void Make2DArray(Type** &x,int rows, int cols)
{ x=new Type*[rows];
for (int i=0;i<rows;i++) x[i]=new Type[cols];
}
How to understand the usage of Type** &x, why it has two **
Type**
is a pointer to a pointer.
Type**&
is a reference to a pointer which points to a pointer.
**
will allow you to make an array of an arrays. This can be used for 2d arrays - x[][]
will work.
精彩评论