make2darraynocatch.h

来自「datastucutre and algorithms, application」· C头文件 代码 · 共 22 行

H
22
字号
// create a 2D array but do not catch exception thrown
// when new fails to allocate sufficient memory

#ifndef make2dArrayNoCatch_
#define make2dArrayNoCatch_

using namespace std;

template <class T>
void make2dArray(T ** &x, int numberOfRows, int numberOfColumns)
{// Create a two-dimensional array.

   // create pointers for the rows
   x = new T * [numberOfRows];
      
   // get memory for each row
   for (int i = 0; i < numberOfRows; i++)
      x[i] = new T [numberOfColumns];
}

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?