What problem are you having trying to do that? It should work as you have it.
BTW, you should not be initializing the pointer in a header file. That initialization should be done in a .cpp file. Initializing the pointer in a header file can cause confusion if the header is included in multiple places.
void changeGamestateOnClick(gameState *GameState)
{
//In here just dereference your pointer and set it to whatever it is you need
*GameState = NEW GAME STATE
}
There is no need to send a pointer as a reference, at least in this case.
so in your code
1 2 3 4
int main()
{
//blah blah
changeGamestateOnClick(GameState);
GameState is already a pointer so just call the function like that
Maybe the function you've called contains the function setGamestate, that says the function setGamestate has not had any code yet.
You defined the function but it seems you haven't written any code for the function setGameState.
Yes like Jackson Marie says, this is a link error. In your .h file you need the function prototype, then in your .cpp file you need the functin definition.
gameState.h
gameState.cpp (setGamestate function is here)
gameMenu.h
gameMenu.cpp (function that requires the gamestate pointer is here)
game.cpp (the pointer gets created here, and the function gets used here)
Inside gamestate.h I define a gamestate class, with a setGameState public function.
Inside gameMenu.h I included gameState.h and I am trying to write a function that changes the gamestate (which uses dynamic memory)'s gamestate.
I took a close look at the paramaters and double checked everything, it's impossible to be a linker error, but what seems to be the problem is this line INSIDE the function that I'm trying to write:
I Found the problem, you were right, I did have the setGamestate function declared properly however for some reason I accidentally erased it, no idea how, but I re-wrote it and mostly everything works as intended.