Bizarre way to 'new' arrays

Lionello Lunesu lio at lunesu.remove.com
Fri Jun 16 00:08:20 PDT 2006


> 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.



More information about the Digitalmars-d mailing list