c++ - Array of Function Pointers Without a typedef -


arrays of function pointers can created so:

typedef void(*functionpointer)(); functionpointer functionpointers[] = {/* stuff here */}; 

what syntax creating function pointer array without using typedef?

arr    //arr  arr [] //is array (so index it) * arr [] //of pointers (so dereference them) (* arr [])() //to functions taking nothing (so call them ()) void (* arr [])() //returning void  

so answer is

void (* arr [])() = {}; 

but naturally, bad practice, use typedefs :)

extra: wonder how declare array of 3 pointers functions taking int , returning pointer array of 4 pointers functions taking double , returning char? (how cool that, huh? :))

arr //arr arr [3] //is array of 3 (index it) * arr [3] //pointers (* arr [3])(int) //to functions taking int (call it) , *(* arr [3])(int) //returning pointer (dereference it) (*(* arr [3])(int))[4] //to array of 4 *(*(* arr [3])(int))[4] //pointers (*(*(* arr [3])(int))[4])(double) //to functions taking double , char  (*(*(* arr [3])(int))[4])(double) //returning char 

:))


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -