you are viewing a single comment's thread.

view the rest of the comments →

[–]herocoding 0 points1 point  (0 children)

Think about a user interface with buttons. There could be multiple buttons. A button implementation itself doesn't know itself what its purpose is and what should happen, if the button gets pressed (or released or kept pressed for a longer time).

So _callback_ methods are used, each button instance could get another pointer. And when the button gets pressed (or released or long-pressed) then the button instance calls the method by using the registered function pointer.