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

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -