How do I store a function to a variable?

前端 未结 7 1892
灰色年华
灰色年华 2020-12-08 08:36

I think they are called functors? (it\'s been a while)

Basically, I want to store a pointer to a function in a variable, so I can specify what function I want to use

7条回答
  •  感情败类
    2020-12-08 08:53

    No, these are called function pointers.

    unsigned int (*fp)(unsigned int) = func_1;
    

提交回复
热议问题