Creating a pointer array
bachmeier
no at spam.net
Wed Aug 19 20:09:31 UTC 2020
On Wednesday, 19 August 2020 at 13:03:54 UTC, data pulverizer
wrote:
> Hi all,
>
> How do you create an array of pointers in D? I tried something
> like
>
> ```
> double* []y;
> ```
>
> Or
>
> ```
> (double*) []y;
> ```
>
> But I get the error:
>
> ```
> Error: only one index allowed to index double[]
> ```
>
> Thanks in advance.
Maybe I'm the only one, but I think double*[] is hideous, and I'd
sure hate for someone not used to D to see it. Alias is your
friend. I think this is much nicer:
void main() {
alias double* DoublePtr;
DoublePtr[] arr;
auto v = [1.0, 2.0, 3.0];
auto w = [4.0, 5.0, 6.0];
arr ~= [v.ptr, w.ptr];
writeln(arr);
}
More information about the Digitalmars-d-learn
mailing list