Imagine I have a button class that has a method called onClick(). Whenever the button is clicked the method onClick() is called. That's all fine and dandy, but there's a problem: every object will need a different method body for their own onClick() method. So my need is this: a way to assign a a new function to a default function in an existing object so I can make my buttons actually do something.
The only thing I've found to help me with this is a function pointer, so pls tell me if you know anything better. Thanks!!
I was trying to avoid having to make a new class for ever button. There has to be a better way than having 30 new classes for 30 new buttons that's only difference is one method.
My example extends button adding a capability to store and change function at runtime.
Another approach would be to use templates for automatic compile0time generation.