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

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -