digitalmars.D - How to create multidimesinal array
- "Andrew Fedoniouk" <news terrainformatica.com> Feb 12 2005
- "Unknown W. Brackets" <unknown simplemachines.org> Feb 12 2005
- Chris Sauls <ibisbasenji gmail.com> Feb 12 2005
- "Andrew Fedoniouk" <news terrainformatica.com> Feb 12 2005
- Chris Sauls <ibisbasenji gmail.com> Feb 13 2005
public struct Color
{
byte r,g,b,a;
};
public Color[][] frameBuffer;
attempt to use:
frameBuffer = new Color[height][width];
where width and height some integer variables produces:
alphablend.d(54): Integer constant expression expected instead of height
alphablend.d(54): cannot implicitly convert expression new Color
[0][](width) of type Color [0][] to Color [][]
Thanks in advance,
Andrew Fedoniouk.
http://terrainformatica.com
Feb 12 2005
For dynamic arrays, you don't use that syntax but rather: frameBuffer.length = height; for (int i = 0; i < height; i++) frameBuffer[i].length = width; -[Unknown]public struct Color { byte r,g,b,a; }; public Color[][] frameBuffer; attempt to use: frameBuffer = new Color[height][width]; where width and height some integer variables produces: alphablend.d(54): Integer constant expression expected instead of height alphablend.d(54): cannot implicitly convert expression new Color [0][](width) of type Color [0][] to Color [][] Thanks in advance, Andrew Fedoniouk. http://terrainformatica.com
Feb 12 2005
Or use
#
# frameBuffer = new Color[height];
# foreach (inout Color[] row; frameBuffer) {
# row = new Color[width];
# }
#
-- Chris S
Unknown W. Brackets wrote:
For dynamic arrays, you don't use that syntax but rather:
frameBuffer.length = height;
for (int i = 0; i < height; i++)
frameBuffer[i].length = width;
-[Unknown]
public struct Color
{
byte r,g,b,a;
};
public Color[][] frameBuffer;
attempt to use:
frameBuffer = new Color[height][width];
where width and height some integer variables produces:
alphablend.d(54): Integer constant expression expected instead of height
alphablend.d(54): cannot implicitly convert expression new Color
[0][](width) of type Color [0][] to Color [][]
Thanks in advance,
Andrew Fedoniouk.
http://terrainformatica.com
Feb 12 2005
Thanks, Chris, Little bit "non-symmetric" with static declaration like int[3][3] but works. Andrew Fedoniouk. "Chris Sauls" <ibisbasenji gmail.com> wrote in message news:cukjsa$15j1$1 digitaldaemon.com...Or use # # frameBuffer = new Color[height]; # foreach (inout Color[] row; frameBuffer) { # row = new Color[width]; # } # -- Chris S Unknown W. Brackets wrote:For dynamic arrays, you don't use that syntax but rather: frameBuffer.length = height; for (int i = 0; i < height; i++) frameBuffer[i].length = width; -[Unknown]public struct Color { byte r,g,b,a; }; public Color[][] frameBuffer; attempt to use: frameBuffer = new Color[height][width]; where width and height some integer variables produces: alphablend.d(54): Integer constant expression expected instead of height alphablend.d(54): cannot implicitly convert expression new Color [0][](width) of type Color [0][] to Color [][] Thanks in advance, Andrew Fedoniouk. http://terrainformatica.com
Feb 12 2005
Yes it does leave one with an odd aftertaste. So Walter, I'd like to reiterate my wishing for a 'new Type[#][#]...' syntax. Would it be very difficult? -- Chris S Andrew Fedoniouk wrote:Thanks, Chris, Little bit "non-symmetric" with static declaration like int[3][3] but works. Andrew Fedoniouk.
Feb 13 2005








Chris Sauls <ibisbasenji gmail.com>