|
-
Dec 10th, 2001, 01:58 PM
#1
Thread Starter
Member
2D array pointers
Hey
Ive been trying to use a 2d Array pointers heres what ive done so far im trying to create a 2d array pointer of type Obj:
[/Start of code]
struct Obj
{
float speed,x,y;
int r,g,b;
bool isDrawn;
};
class cBuilding
{
Obj **bld;
etc......
};
cBuilding::cBuidling()
{
bld = new Obj*[21]; //Pointers to 21 arrays
for (int c=0; c<21; c++)
{
bld[c] = new Obj[7]; //Creates an array for each pointer in bld array
}
}
cBuilding::~cBuilding()
{
for (int c=0; c<21; c++)
{
delete [] bld[c];
}
delete [] bld;
}
[/End of code]
it just crashes my program please help me im desperate :D
Thanks
Chris
What is Life? One big dream or one Big nightmere.
-
Dec 10th, 2001, 03:59 PM
#2
Fanatic Member
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 10th, 2001, 06:53 PM
#3
transcendental analytic
That's not a 2d array but an array of arrays. I recommend you use a single array and dynamically dimension it into 2d, so that you can access it by bld[a+b*width];
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|