I have a struct array in one of my classes, which itself has an setup method.
struct key
{
int x;
int y;
};
class myClass
{
key theKeys[9];
void setup();
};
in the setup method I go through them but they stay the same
void myClass::setup()
{
for (int i = 0; i < 9; i++)
{
theKeys[i].x = i;
theKeys[i].y = i - 1;
cout << theKeys[i].x << " " << theKeys[i].y << endl;
}
}
Will return
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
What am I doing wrong? Bear in mind this isn't the actual code from my project, but its pretty much the same.
Solved: WOOPS, I fixed it. I wan't go into detail but it actually was working but cout wasn't set up properly so it print the wrong struck that hasn't been set yet.
new
operator?setup
to be called). Please post some code that demonstrates teh problem.