c++ - How to store various types of function pointers together? -



c++ - How to store various types of function pointers together? -

normal pointers can stored using generic void*. e.g.

void* arr[10]; arr[0] = pchar; arr[1] = pint; arr[2] = pa;

sometime back, came across give-and-take that, void* may not capable plenty store function pointer without data-loss in platforms (say 64-bit , more). not sure fact though.

if that's true, portable way store collection of function pointers ? [note: this question doesn't satisfactorily reply this.]

edit: storing function pointers index. there typecasting associated every index whenever collection accessed. of now, interested create array or vector of it.]

you can convert function pointer function pointer of function type , without loss.

so long when create phone call through function pointer typecast right type first, can store of function pointers in like:

typedef void (*fcn_ptr)(void); // 'generic' function pointer fcn_ptr arr[10];

c++ c function-pointers

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -