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];//创建rows行cols列的动态数组
}
}
template < class Type >
void Delete ( Type ** &x , int rows , int cols )
{
for ( int i = 0 ; i < rows ; i ++ )
{
delete []x[i] ;//释放每行所分配的空间
}
delete []x ;//释放为行指针分配的空间
x = 0 ;
}
别忘了运算符new的妙处。。。动态存储分配
