c++ - Use `delete []` when `new [0]` -
this question has answer here:
- c++ new int[0] — allocate memory? 5 answers
i dynamically allocated array (unsigned int n might have been passed parameter in function):
int * ar = new int [n]; when i'm done using it:
delete [] ar; but, happens when n = 0? allocate 0 ints same not allocating @ all? in case, bad things happen when call delete?
it's ok new zero-sized array, , delete it. more of convenience anything, means don't have write separate conditions 0 case.
Comments
Post a Comment