Hi,
For uni we have go some c# memory mangment cw to do. though i have got stuck at a point. ill try to explane:
Some of the code we have to work with:
Now we ahve to discribe the memory mangment of this section in terms of stack and heap.
Dose nextPositions go on the stack when its declaired at the start or dose it only go on the stack + heap when (nextPositions = new Board...)
Any help would be great!
Thanks
For uni we have go some c# memory mangment cw to do. though i have got stuck at a point. ill try to explane:
Some of the code we have to work with:
Code:
// computes the board positions achieved by 1 more move
public Board[] NextPositions () {
Counter nextCounter;
Board[] nextPositions;
int nextBoardPos = 0;
if ((NumberOfCounters % 2) == 0)
nextCounter = Counter.X;
else nextCounter = Counter.O;
nextPositions = new Board[9-NumberOfCounters];
for (int row=0; row<3; row++)
for (int col=0; col<3; col++)
if (Position[row,col] == Counter.None) {
nextPositions[nextBoardPos] = new Board (this, row, col, nextCounter);
++nextBoardPos;
int x=0;
x++;
Console.WriteLine (x);
}
return nextPositions;
} // end NextPositions method
Now we ahve to discribe the memory mangment of this section in terms of stack and heap.
Dose nextPositions go on the stack when its declaired at the start or dose it only go on the stack + heap when (nextPositions = new Board...)
Any help would be great!
Thanks