Possible Duplicate:
What is the point of function pointers?
I just read about pointers to function in K+R. I understand how these pointers work, but I don’t see the utility for they. What’s the use for this type of pointers in programming?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use function pointers for a variety of tasks such as registering factories, applying an algorithm on a data structure (e.g. sorting a list using a user-defined sort function). There are a few other uses but essentially you need them for inversion of control: let someone else call back into your code, and you do this by providing a pointer to the function.