Function pointer | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Function pointer

Unable to understand function pointer and it's application.

17th Jun 2020, 4:40 PM
Rahul Singh
Rahul Singh - avatar
2 ответов
Mainly used for callback mechanism and events of the components. Read these answers:
18th Jun 2020, 2:40 AM
Vasile Eftodii
Vasile Eftodii - avatar
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 - avatar