Unexpected value change

I'm writing a code that saves some values to an array in a class Grid. However, my index number changes mid code from 0 to 1, and I have no idea why. Please help

1
2
3
4
5
6
7
8
9
void Grid::setTraps(int x, int y){
	traps = 0;
	cout << traps;
	trapX[traps] = x;
	cout << traps;
	trapY[traps] = y;
	cout << traps;
	grid[y][x] = 'T';
}


The first cout sends out a 0 (as expected), but the next two put out a 1.
Thank you
Are you sure trapX[traps] is not out of bounds?
Topic archived. No new replies allowed.