|
Re: C++ help: Understanding pointers?
You're very close with your code, but you actually need a 3rd level of indirection.
int*** p3Dimensions = new int**[width];
for(int x = 0;x < width; x++)
{
p3Dimensions[x] = new int*[height];
for(int y = 0;y < height; y++)
{
p3Dimensions[x][y] = new int[depth];
for(int z = 0;z < depth; z++)
{
p3Dimensions[x][y][z] = x*y*z;
}
}
}
I'm pretty tired from practice day at waterloo, so I'll let you figure out how that works ... if it compiles, which it might not.
|