Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Deleting a pointer's target array element

$
0
0
In the code
SOME_CLASS* class_arr = new SOME_CLASS[4];



I know i can delete the entire pointer's target by
delete class_arr


, but why cant i delete the second element in the pointer's target's array
delete (class_arr+2)
, for example?


My guess is that this method of allocating the memory will allocate memory consequtively and form a certain continuity between the 4 class objects on the heap, and breaking this contunity between each element is not allowed, but i really have no clue.

Thanks!
and Happy Holidays.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>