What does “typedef void (*Something)()” mean

后端 未结 5 499
星月不相逢
星月不相逢 2020-12-02 14:38

I am trying to understand what this means, the code I am looking at has

in .h

typedef void (*MCB)();
static MCB     m_process;

in .

5条回答
  •  Happy的楠姐
    2020-12-02 14:49

    Let's take an example

    typedef void (*pt2fn)(int);
    

    Here, we are defining a type pt2fn. Variables of this type point to functions, that take an integer as argument and does not return any value.

    pt2fn kk;
    

    Here, kk is a variable of type pt2fn, which can point to any function that takes in an integer as input and does not return any value.

    Reference:https://cs.nyu.edu/courses/spring12/CSCI-GA.3033-014/Assignment1/function_pointers.html

提交回复
热议问题