c++ - delete[] Array of characters -
possible duplicate:
delete[] supplied modified new-ed pointer. undefined behaviour?
let's i've allocated handful of characters using new char[number]
.
will possible delete few end characters (something delete[] (chararray + 4);
, supposedly de-allocate of characters except first four)?
i read implementations' new[]
store number of objects allocated before array of objects delete[]
knows how many objects de-allocate, it's unsafe i'm asking...
thanks.
edit:
is manually deleting unwanted end bytes using separate delete
statements safe way i'm asking?
the "safe" way allocate new array, copy data, , delete old one. or follow std::vector
way , differentiate between "capacity" (the size of array) , "size" (the amount of elements in it).
Comments
Post a Comment