您的位置:首页 > 其它

简单二维数组模板类

2008-05-28 20:16 183 查看
template<class T>
class Array{ 
public:
 Array(int row,int col);
 ~Array();
 T** GetArray(){return array;}
 int GetRow(){return _row;}
 int GetCol(){return _col;}
private:
 int _row;
 int _col;
 T** array;
};
template<class T>
Array<T>::Array(int row,int col):_row(row),_col(col)
{
 array=new T*[row];
 for(int i=0;i<row;i++)
  array[i]=new T[col]; 
}
 
template<class T>
Array<T>::~Array()
{
 for(int i=0;i<_row;i++)
  delete [] array[i];
 delete [] array;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  delete