Hi,
This is not so much a direct technical question (yet) but a call for help to move in the right direction.
I hope this is not too long of a question, but fear it may be.
Problem statement
=================
1.) i have a game class
2.) i have a generic button class
3.) i have a generic menu class
4.) I have button and menu members of game class and they both are drawn on the screen
5.) I want, when the button is pressed, for the menu to open if its currently closed
This got me to thinking that my generic button class needs some way of storing a callback function for what to do when the button is pressed.
I started researching callback functions, function pointers, std::function, std::bind, etc and with those were examples that made basic assumptions.
Some of the examples were dealing only with basic functions and not member functions of specific objects.
After looking at a lot of answers and syntax I realized the TOP answer here came closest to describing what I'm trying to do, but still not quite because its hard-coding class type and I haven't really tried using templates at all yet.
http://stackoverflow.com/questions/10537131/how-to-pass-a-method-as-callback-to-another-classIt may be what I'm trying to do is just
too far beyond my current C++ skill level?.
On the same question, there was an answer by Ed Heal that looked like an intriguing alternative that may not be as complicated to implement, wondering what people here thought of his answer to use pure virtual functions instead of typedef with std::function to avoid some of the complexity.
Thanks.