Re: Constructing arrays of structs

2024-01-23 Thread Danilo via Digitalmars-d-learn
On Tuesday, 23 January 2024 at 18:15:29 UTC, Stephen Tashiro wrote: If the constructor of a class needs to create an array of structs whose dimensions are inputs, what's the syntax for doing this? For a non-example, the following program errors in main() because in t.array[][] "index [0] is o

Re: Constructing arrays of structs

2024-01-23 Thread Renato via Digitalmars-d-learn
On Tuesday, 23 January 2024 at 19:32:31 UTC, Stephen Tashiro wrote: Thank you. I don't really understand what the syntax new Point[][](the_dimension,the_dimension); denotes. Does it represent a function? To look up this topic, what are the proper keywords? By experimentation, I found tha

Re: Constructing arrays of structs

2024-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 23, 2024 12:32:31 PM MST Stephen Tashiro via Digitalmars- d-learn wrote: > On Tuesday, 23 January 2024 at 18:23:22 UTC, Renato wrote: > > This works , your mistake was to not actually assign the array > > to the class' field! > > > > Change this line: > > > > ```d > > auto array

Re: Constructing arrays of structs

2024-01-23 Thread Stephen Tashiro via Digitalmars-d-learn
On Tuesday, 23 January 2024 at 18:23:22 UTC, Renato wrote: This works , your mistake was to not actually assign the array to the class' field! Change this line: ```d auto array = new Point[][](the_dimension,the_dimension); ``` To this: ```d this.array = new Point[][](the_dimension,the_dimens

Re: Constructing arrays of structs

2024-01-23 Thread Renato via Digitalmars-d-learn
On Tuesday, 23 January 2024 at 18:15:29 UTC, Stephen Tashiro wrote: If the constructor of a class needs to create an array of structs whose dimensions are inputs, what's the syntax for doing this? For a non-example, the following program errors in main() because in t.array[][] "index [0] is o

Constructing arrays of structs

2024-01-23 Thread Stephen Tashiro via Digitalmars-d-learn
If the constructor of a class needs to create an array of structs whose dimensions are inputs, what's the syntax for doing this? For a non-example, the following program errors in main() because in t.array[][] "index [0] is out of bounds". import std.stdio; struct Point { uint