What's the syntax for declaring an array of function pointers without using a separate typedef?

后端 未结 3 691
Happy的楠姐
Happy的楠姐 2020-12-12 19:16

Arrays of function pointers can be created like so:

typedef void(*FunctionPointer)();
FunctionPointer functionPointers[] = {/* Stuff here */};
3条回答
  •  暖寄归人
    2020-12-12 19:51

    Remember "delcaration mimics use". So to use said array you'd say

     (*FunctionPointers[0])();
    

    Correct? Therefore to declare it, you use the same:

     void (*FunctionPointers[])() = { ... };
    

提交回复
热议问题