How do I store a function to a variable?

前端 未结 7 1912
灰色年华
灰色年华 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 09:06

    typedef unsigned int (*PGNSI)(unsigned int);
    
    PGNSI variable1 = func_1;
    PGNSI variable2 = func_2;
    

提交回复
热议问题