Different ways to deallocate an array – c++

new type requires delete
new type[size] requires delete []
Using one instead of the other is wrong.

Btw you should not use such raw pointers like this unless you have a very good reason. Use std::vector or std::array instead.

And 2D MxN arrays should generally be linearised into 1D M*N arrays, also using these containers.

Leave a Comment