I have a widget class that displays values on a dashboard. These values are generated by several other classes measuring different stuff. While configuring the widgets, I would like to store a pointer to the function that delivers the value for this widget in a member variable of the widget. When rendering, the widget calls this function using the pointer and is good to go.
That means I have to create a member variable in my widget class that is a pointer to a member function of an instance of another class. Is that even possible? This is what I have tried:
This is how it SHOULD work as far as I understand. I get a "error: 'get_value_ptr' was not declared in this scope" from the compiler.
Can somebody explain what happens here?
BTW: I ideally would like the pointer "get_value_ptr" to not be bound to one source class as it is now. But that is something to think about in a second step ;-)
Very cool, thank you all for the quick replies! I will now try to understand them ;-) https://www.newty.de/fpt/callback.html looks very interesting in my context.