View Single Post
  #15   Spotlight this post!  
Unread 22-03-2012, 20:50
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
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.