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

前端 未结 9 2350
野趣味
野趣味 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:28

    I'm surprised no one mentioned "state machines". Function pointers are a very common way to implement state machines for tasks such as parsing. See for example: link.

提交回复
热议问题