| maynard 2006-01-24, 7:07 pm |
|
Igor Tandetnik wrote:
>
> Second, the pointer returned by new[] expression may not point to the
> beginning of the allocated memory, and usually doesn't. Again, the
> compiler usually requests more memory than would be occupied by the
> elements themselves. It stores certain housekeeping information (at
> least, the number of the elements allocated) at the beginning of the
> block, and returns a pointer that points right after this internal data.
Ah, so the behavior is compiler specific? I must pay better attention
to the examples I find on websites :-)
>
> Bottom line: the only thing operator new can do is allocate raw memory.
> There's no point writing anything into this memory (except perhaps
> filling it with a distinct bit pattern for debugging purposes) - it will
> essentially be wiped out and repaved when constructors are run.
Now I understand. Thanks for your help Igor.
|