Hey,

Many of you will know what i am doign, but for those who don't :

I am creating a 3D draughts/checkers game. My squares on the board are linked to one draught. and my draughts are linked to a certain square. Now your are able to get the draught you want by entering the index number of it. But i don't want that, i want to get the draught on the square by entering the co-ordiantes of the square and then retrieve the draught on the square, without entering the draught index number. I will show how each my get methods work:

This is how i create the squares in my board.cpp and the i have created that method of retreiving them. So if i wanted a square diagonally right from my current square, i woud just do :Code:Board::Board(int x, int y){ squares = (Square **) malloc(sizeof(Square *) * x); for(int i=0; i<x; i++) squares[i] = (Square *) malloc(sizeof(Square) * y); for(int i=0; i<x; i++) for(int j=0;j<y; j++) squares[i][j].setXY(i, j); sizeX=x; sizeY=y; } Square * Board::getSquare(int x, int y) { if (x<0 && x>=sizeX) {} else if (y<0 && y>=sizeY) { return NULL; } else{ return &squares[x][y];} }

Now i want a method in my player.cpp where i can retrieve the draughts in a similar way, without using hte index number. So if i entered get a certain square and then get that draught of that square.Code:Square * t = board->getSquare(s->getX() - 1, s->getY() - 1);

This is where i allocate memory and give the player a number of draughts each with its own

index number. atm i have a way of gettin the draugh tbut only through the index number:

Is there a way already of gettin the draught on a certain square without creating a method? If not, then i would welcome some help on how to do it, can't think of a way, im not so good at programming, sorry if this is very simple, but it isn't to me!!!Code:Draught * Player::getDraught(int index) { return &draughts[index]; }

thank you!