Goal is to create a simple class that can be used for GUI buttons. My question is how can I define a function variable, and then when constructing a 'button' define which function should be called when clicked.
This obviously isn't right, but just to get the idea:
class button {
private:
function whenClicked;
public:
button(function f1) : whenClicked(f1) {}
};
I've read that its possible to pass a function as a parameter, but I don't think that's what I'm looking for. I'd like to have all the functions defined once when created, and not pass the function every time the button's called. I think that will make it easier to cycle through a list or array and check if pressed and execute the appropriate function.
I hope I'm making sense here, thanks for any help