What are function pointers used for, and how would I use them?

前端 未结 9 2320
野趣味
野趣味 2020-11-29 06:51

I understand I can use pointers for functions.

Can someone explain why one would use them, and how? Short example code would be very helpful to me.

9条回答
  •  温柔的废话
    2020-11-29 07:30

    One quite common use case is a callback function. For example if you load something from a DB you can implement your loading function so that it reports the progress to a callback function. This can be done with function pointers.

提交回复
热议问题