c++ - Delete array from an offset -
lets allocate array of ints
int test[] = new int[100]; i take pointer somewhere in middle
int *temp = &test[50]; then call delete[] on temp
delete[] temp how compiler know size of elements delete in case?
it won't (or will, don't know). you're invoking undefined behavior. you're allowed call delete[] on pointer allocated new[].
for example, crash in msvs.
Comments
Post a Comment