简单二维数组模板类
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;
}
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;
}
相关文章推荐
- C++:简单的二维数组模板类
- 标准类库 queue模板类的简单实现
- list 模板类的简单实现
- 实现简单容器模板类Vec(vector capacity 增长问题、allocator 内存分配器)
- 一个实现了iterator模式的简单模板类
- php对二维数组进行排序的简单实例
- 二维数组指针的简单使用
- 从零开始学习c++之一维、二维数组和vector的简单使用
- 第一次做二级联动,没有用到对象与二维数组(笨方法,思路简单)
- C语言里动态二维数组的构造及最简单使用范例
- 二维数组操作(编程题---简单)
- 简单的输入输出、一维数组、二维数组、普通遍历、使用foreach语句遍历数组操作
- vector模板类之简单程序代码(初始化、迭代器、大小、容量以及删除等操作)
- 最简单的指针与地址练习(二维数组)0
- shared_ptr智能指针模板类的简单实现(c++11)
- 简单的输入输出、一维数组、二维数组、普通遍历操作
- boj 1347 简单数组问题 在一个二维数组中 a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1] 则a[i][j]为i j位置左上侧所有元素之和
- Day7-指针的基础详解、二维数组、数组的几种应用、字符串的简单应用.pages
- 【C语言简单说】十八:二维数组
- 1036. Crypto Columns数组与下标(二维数组) 简单