Why “delete [][]… multiDimensionalArray;” operator in C++ does not exist

后端 未结 9 994
清酒与你
清酒与你 2021-02-05 06:09

I was always wondering if there is operator for deleting multi dimensional arrays in the standard C++ language.

If we have created a pointer to a single dimensional arra

9条回答
  •  粉色の甜心
    2021-02-05 06:36

    The reason delete is called multiple times in that example is because new is called multiple times too. Delete must be called for each new.

    For example if I allocate 1,000,000 bytes of memory I cannot later delete the entries from 200,000 - 300,00, it was allocated as one whole chunk and must be freed as one whole chunk.

提交回复
热议问题