How to set array length for multidimensional static arrays

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 1 03:38:17 PST 2016


V Mon, 01 Feb 2016 11:15:40 +0000
Namal via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsáno:

> Sorry guys that I didn't express myself well. I also mixed some 
> stuff up. What I wanted to ask is this, in c++ this is valid
> 
> 	int x = 3;
> 	int y = 10;
> 	int arr [x][y];
> 
> x,y are known at the compile time and arr is a static array. I 
> can't do that in D so what is the best way to declare an array of 
> that size?

You can do that:
immutable x = 3;
immutable y = 10;
int[y][x] arr;



More information about the Digitalmars-d-learn mailing list