
15 Mar
2009
15 Mar
'09
2:51 p.m.
AMDG herve martin wrote:
For some reason reference on C array is almost never used by developers even if a reference on C array encapsulates more information than just a pointer on the 1st element. A striking example is that the dynamic allocation of an array using the new syntax returns a pointer on first element ( int *ptr = new int[10]; ) although I would expect getting a pointer on an array ( int (*ptr)[10] = new int[10]; - this syntax fails but is more conform to what we could expect, even if I must admit that the second syntax is not really intuitive -).
new[] has to return a pointer because the size doesn't have to be known at compile time. In Christ, Steven Watanabe