标签:blog os io for ar 2014 cti div
/******************************************************************** @file Main_practise.cpp @date 2014-8-15 @author Tiger @brief 二维数组 @details 为一个二维数组分配存储空间。 ********************************************************************/ #include <iostream> #include <vld.h> const int ROW = 3; const int COL = 3; template <typename T> void Make2DArray(T**& arr, int nRows, int nCols); template <typename T> void Delete2DArray(T**& arr, int nRows); int main(int argc, const char* argv[]) { int** arr = NULL; Make2DArray(arr, ROW, COL); Delete2DArray(arr, ROW); system("pause"); return 0; } template <typename T> void Make2DArray(T**& arr, int nRows, int nCols) { arr = new T*[nRows]; for (int i=0; i<nRows; ++i) { *(arr+i) = new T[nCols]; } } template <typename T> void Delete2DArray(T**& arr, int nRows) { for (int i=0; i<nRows; ++i) { delete [] *(arr+i); } delete [] arr; arr = NULL; }
标签:blog os io for ar 2014 cti div
原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/3913920.html