Array of array

Matej Nanut matejnanut at gmail.com
Mon Jan 2 15:46:40 PST 2012


On 3 January 2012 00:27, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 01/03/2012 12:03 AM, RenatoL wrote:
>
>> I have:
>>
>> auto r = new int[][];
>>
>> Error: new can only create structs, dynamic arrays or class objects
>> , not int[][]'s
>>
>> while
>>
>> auto r = new int[][3];
>>
>> is ok.
>>
>
> new int[][3] is an alternate form of new int[][](3); new int[][3]
> allocates an int[][] with 3 default-initialized elements.
>

I assume `int[][] sth;` does what RenatoL wants to accomplish by `auto sth
= new int[][];`. I do however have a question:
is `auto sth = new int[][5];` the same as `int[][5] sth;`? If not, what is
the difference?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120103/8c58e69f/attachment.html>


More information about the Digitalmars-d-learn mailing list