I have been working on this for a few hours now and I am unable to resolve the problem.
I have a class (named tictactwice), and a struct inside (declared as a static variable). The purpose of this struct is to hold two integers, indices into a double array:
Then, I need an array of these structs (must hold 16 of them). So it is declared as another static variable as:Code:struct arrayIndex { int i; int j; };
struct arrayIndex TRANSPOSE[4][4];
So far, so good. The problem is trying to initialize this TRANSPOSE array in the implementation file. It just doesn't happen - I don't get a compiler error, but it doesn't work:
THIS does not initialize the structs inside - I get junk when I try to access any of them:Code:struct tictactwice::arrayIndex TRANSPOSE[4][4] = {{{2,3},{0,0},{1,2},{3,1}}, {{1,1},{3,2},{2,0},{0,3}}, {{3,0},{1,3},{0,1},{2,2}}, {{0,2},{2,1},{3,3},{1,0}}};
TRANSPOSE[0][0].i gives 2012756197.
But when I try something like:
struct tictactwice::boardIndex test = {-1, -1}; // a stand-alone struct
IT WORKS - e.g. test.i = -1 and test.j = -1. So, I can initialize each little struct individually but not when they are inside the array. Oh, I also tried placing 16 initialized "test" structs in the array, but it STILL doesn't work:
TRANSPOSE[0][0].i = JUNK again....while test.i = -1.Code:struct tictactwice::arrayIndex TRANSPOSE[4][4] = {{test,test,test,test}, {test,test,test,test}, {test,test,test,test}, {test,test,test,test}};
Maybe I am accessing the structs in the array wrong - I don't understand what is happening and how come the "test" struct becomes inaccessible once stuck in this array, while it is perfectly initialized when being outside.
ANY suggestions and help are very welcome!!!