+ 1

Function pointer

Unable to understand function pointer and it's application.

17th Jun 2020, 4:40 PM
Rahul Singh
Rahul Singh - avatar
2 ответов
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
18th Jun 2020, 2:40 AM
Vasile Eftodii
Vasile Eftodii - avatar
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.
18th Jun 2020, 11:09 AM
Gen2oo
Gen2oo - avatar