delete multidimensional arrays

后端 未结 5 1949
醉梦人生
醉梦人生 2021-01-24 00:43

In C++ FAQ, the [16.16] gives the following example,

void manipulateArray(unsigned nrows, unsigned ncols[])
{
   typedef Fred* FredPtr;
   FredPtr* matrix = new          


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 01:23

    The catch block in the try...catch is there to delete the matrix if an exception was thrown, and then re-throw the exception.

    If no exception is thrown, the catch block never gets hit, and the matrix has to be deleted on the way out through the normal exit of the routine.

提交回复
热议问题