関数ポインタの配列は次のように作成できます。
typedef void(*FunctionPointer)();
FunctionPointer functionPointers[] = {/* Stuff here */};
を使用せずに関数ポインター配列を作成するための構文は何ですかtypedef
?
ベストアンサー1
arr //arr
arr [] //is an array (so index it)
* arr [] //of pointers (so dereference them)
(* arr [])() //to functions taking nothing (so call them with ())
void (* arr [])() //returning void
あなたの答えは
void (* arr [])() = {};
しかし、当然ながら、これは悪い習慣なので、単に使用してくださいtypedefs
:)
余分な:int を受け取り、double を受け取り char を返す関数への 4 つのポインターの配列へのポインターを返す関数への 3 つのポインターの配列を宣言する方法を知りたいですか? (なんてクールなんでしょう? :))
arr //arr
arr [3] //is an array of 3 (index it)
* arr [3] //pointers
(* arr [3])(int) //to functions taking int (call it) and
*(* arr [3])(int) //returning a pointer (dereference it)
(*(* arr [3])(int))[4] //to an array of 4
*(*(* arr [3])(int))[4] //pointers
(*(*(* arr [3])(int))[4])(double) //to functions taking double and
char (*(*(* arr [3])(int))[4])(double) //returning char
:))