+ 1
Function pointer
Unable to understand function pointer and it's application.
2 odpowiedzi
0
Mainly used for callback mechanism and events of the components. Read these answers:
https://stackoverflow.com/questions/8975208/what-is-the-use-of-function-pointers
0
They're often use for generics in C. An example of that would be qsort() which accepts a function pointer to do comparisons between any two types.
You can also embed them in a structure if that function pointer is accessed frequently for that structure and you don't want to pass it as an argument to every function that requires it. It would then emulate class function calls in OOP.