Bizarre way to 'new' arrays
Gregor Richards
Richards at codu.org
Fri Jun 16 11:25:42 PDT 2006
Lionello Lunesu wrote:
>> int* i = (new int[5]).ptr;
>
>
> No, he wants to allocate 1 int and initialize it to 5.. Exactly what the
> code would do in C++:
>
> // allocate 1 int and initialize it to 5
> int* i = int(5);
>
> (I found this out when I had to hunt a bug once and it turned out
> somebody had used (5) instead of [5] )
>
> L.
Oh, sorry, misunderstood :)
- Gregor Richards
More information about the Digitalmars-d
mailing list