I have a class that contains coordinates for a square.
I set the values, and then right afterwards, I try to access them ,and every index is the same as the last one!
Anyone know why this is?
Code:
tile block[3][3];
for (p=0;p<3;p++)
{
for (i=0;i<3;i++)
{
block[i][p].setX(curX);
block[i][p].setY(curY);
block[i][p].setWidth(TWidth);
block[i][p].setHeight(THeight);
printf("%d %d %d %d \n", block[0][0].getX(),block[0][0].getY(),block[0][0].getWidth(),block[0][0].getHeight());
curX = curX+TWidth+20;
}
curX=50;
curY= curY+THeight+10;
}
printf("%f %f %f",block[0][0].getRf(),block[0][0].getGf(),block[0][0].getBf());
for (p=0;p<3;p++)
{
for (i=0;i<3;i++)
{
printf("%d %d %d %d \n", block[i][p].getX(),block[i][p].getY(),block[i][p].getWidth(),block[i][p].getHeight());
printf("\n");
}
}
and the output
50 50 50 50
120 50 50 50
190 50 50 50
50 110 50 50
120 110 50 50
190 110 50 50
50 170 50 50
120 170 50 50
190 170 50 50
1.000000 0.000000 0.000000190 170 50 50
**
*******Right here is where it starts outputting the numbers again after the loop
**
190 170 50 50
190 170 50 50
190 170 50 50
190 170 50 50
190 170 50 50
190 170 50 50
190 170 50 50
190 170 50 50