Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you write something like this? (intentionally not using delete [] on an array)

Tags:

People also ask

Can you use Delete on an array?

Delete is an operator that is used to destroy array and non-array(pointer) objects which are created by new expression.

What is difference between delete and delete brackets?

Show activity on this post. You delete [] when you new ed an array type, and delete when you didn't.


I came across this kind of code once in a while - I suspect the creator is/was afraid that table delete would iterate over the table and "cost performance" (which imho will not be done either way)... is there any real benefit one might get/consider/imagine from not using the the table delete here?

myClass** table = new myClass* [size];
... //some code that does not reallocate or change the value of the table pointer ;)
delete table; // no [] intentionally