I am currently working on a rudimentary simulator for the game Boggle, and right now I have gotten to the point where I need to use pointers to an object in a function call. However, I am unsure of how to do this, and thus far my search on this site and elsewhere has not proved fruitful, seeing as from what I have seen the questions have not been about pointers to objects. The following is my code for the function being called from a class, the initialization of the objects, and my attempted function calls. The setAdjacency function is found in the class boggleNode.
void setAdjacency(boggleNode * topleft = NULL, boggleNode * top = NULL, boggleNode * topright = NULL,
boggleNode * left = NULL, boggleNode * right = NULL, boggleNode * botleft = NULL, boggleNode * bot = NULL, boggleNode * botright = NULL){
adjacency[0] = topleft;
adjacency[1] = top;
adjacency[2] = topright;
adjacency[3] = left;
adjacency[4] = right;
adjacency[5] = botleft;
adjacency[6] = bot;
adjacency[7] = botright; //For keeping track of which nodes are adjacent to which other ones.
}
These are the private variables in boggleNode:
private:
boggleNode * adjacency[8];
char letter;
bool isUsed;
"Board" is defined as follows:
boggleNode * board = new boggleNode[16];
And finally, here is where I attempt to call the adjacency function in my main function:
board[0].setAdjacency(board[1], board[4], board[5]);
I am aware that currently the arguments in this function call are references, whereas they are supposed to be pointers in the function definition. How do I get the function call and the function definition to align properly?
I am aware that currently the arguments in this function call are referencesI don't see references in that call. You are passingboggleNodeinstances. Maybe you are getting confused withJava?