Expand|Select|Wrap|Line Numbers
- class Solution
- {
- private:
- int *HeuristicTours;
- public:
- int* GetTours()
- {
- return HeuristicTours;
- }
- };
Expand|Select|Wrap|Line Numbers
- int run(Problem &p)
- {
- int **m_ppiTourMatrix_bestsofar; // declared globally so cleanup() can access
- int *piNext, *piTours;
- ...
- piNext = p.solution.GetTours();
- for (i=0; i<p.solution.HeuristicVehicleCount; i++)
- {
- iCount = m_ppiTourMatrix_bestsofar[i][0];
- for (j=1; j<=iCount; j++)
- {
- *piNext = m_ppiTourMatrix_bestsofar[i][j];
- piNext++;
- }
- *piNext = -1;
- piNext++;
- }
- cleanup();
- return 0;
- }
- void cleanup()
- if (m_ppiTourMatrix_bestsofar != NULL)
- {
- free(m_ppiTourMatrix_bestsofar);
- m_ppiTourMatrix_bestsofar = NULL;
- }
The problem I have is that although the values are set fine before calling cleanup(), as soon as cleanup() has been called my values within my solution tours are now uninitalised.
I thought that
Expand|Select|Wrap|Line Numbers
- *piNext = m_ppiTourMatrix_bestsofar[i][j];
Thanks for your help.