Arguments/parameters in a callback

I am taking my first C++ college class and we are learning the callback concept. I have the code below that is actually working (it is a callback code that responds to a button click), were "pancakesScreen" is a global variable but I need to define it locally at some point in the code. If I define it locally then my code below will not work so I suppose that it can be passed as an argument. Is it possible to pass it as an argument/parameter? If so, how?

1
2
3
4
5
6
  void cb_btnFlip8(Fl_Widget*, void*)
{
	UpdateFlipsCount();
	FlipPancakes(8);
	pancakesScreen.redraw();
}
Shouldn't it work simply to pass pancakesScreen by reference(or a pointer to it)? Assuming you have access to the screen object locally in the calling function.
Last edited on
Topic archived. No new replies allowed.