hey folks, i have a problem which seems to be reasonably simple but i havnt managed to figure it out yet. Iv read alot of the other threads on this but i still havnt found one that iv both understood and solved my problem. So here goes...
Its concerning returning a member variable, that is a 2d array made within a class, to the program.
//located in the class header file
int** m_iPopulation;
//located in the class constructor
m_iPopulation = new int* [m_iPopDensity];
for(unsigned short int i=0; i<m_iPopDensity; i++)
m_iPopulation[i] = new int [m_iChromeLength + 4];
the above all works fine, i can see the population when i fill the array and i can print them to the screen etc. The problem comes when i try to return the above array to the main program.
//located in class header file
inline int** GetPopulation(){return m_iPopulation;};
//located in the main() program
int** iPopulation = new int* [iPopDensity];
for(unsigned short int i=0; i<iPopDensity; i++)
iPopulation[i] = new int [iChromeLength + 4];
iPopulation = _pGA->GetPopulation();
when i try to print whats in the array all i get is 1 memory address. and when i debug all i can see is a single entry in the array.
not sure what im doing wrong and i cant find anything else on the fora to help me, so any help is greatly appriciated.
thx!