struct MAP
{
MAP *lpNext;
MAP *lpPrev;
DWORD dwTerrain;
DWORD dwIndex;
};
class CMap
{
MAP *m_aMap[][];?????
}
AND
when allocating
m_aMap= new MAP[][100]; ???
Please and thanks.
I am actually a Swede, living in paradise.
Help! 2-dim array and new
How do I dynamically allocate a two dimensional array?
Declare what in the private: section of the class
It should be OK with only the pointer like this
MAP *m_aMap;
Then you can allocate the memory with ney just as you did it!
m_aMap = new MAP[100][100];
Because in C++ pointers and indexed Arrays are pretty much the same thing you can adress it afterwards with something like this
m_aMap[70][20] = 15;
I hope that did help!
MAP *m_aMap;
Then you can allocate the memory with ney just as you did it!
m_aMap = new MAP[100][100];
Because in C++ pointers and indexed Arrays are pretty much the same thing you can adress it afterwards with something like this
m_aMap[70][20] = 15;
I hope that did help!
>MAP *m_aMap = new MAP[100][100];
You can''t do that. Do this:
Or made it a one-dimensional array and when indexing into (i, j) have it index into i*numberOfRows+j.
You can''t do that. Do this:
MAP **m_aMap = new MAP*[100];for (int i = 0; i < 100; i++) { m_aMap[i] = new MAP[100];}
Or made it a one-dimensional array and when indexing into (i, j) have it index into i*numberOfRows+j.
Sorry Master Jazzman but I tried that without success...
I´ll try the other suggestion later on, for now I keep it static but it has to be dynamic later on.
Thanks both of you.
I´ll try the other suggestion later on, for now I keep it static but it has to be dynamic later on.
Thanks both of you.
you could make it one-dimensional, and index it yourself:
you oughtta be able to figure out what those spare variables are for...
--- krez (krezisback@aol.com)
// create itint* tG = new int[nWidth * nHeight];// use ittG[x + y * nWidth] = p_def_alt;
you oughtta be able to figure out what those spare variables are for...
--- krez (krezisback@aol.com)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement