2 ms·
Of course, the correct way to use a function pointer is to call it.
by saagarjha 11mo ago
Of course, the correct way to use a function pointer is to call it.
- nitrix 11mo agoYes, the () operator dereference function pointers automatically for you for convenience. There's also the surprise that you can infinitely dereference function pointers as they just yield you more function pointers.
- korianders 11mo agoOne baffling thing I see people do with typedefing function pointers is insisting on adding in the pointer part in the typedef which just complicates and hides things. If you want to typedef a function pointer, make a completely ordinary function declaration, then slap 'typedef' at the beginning, done. This does require you to do "foo_func *f" instead of "foo_func f" when declaring variables, but that is just clearer imo. typedef int foo_func(int); // nice typedef int (*foo_func)(int); // why?
- cryptonector 11mo agoWhy do you need the `*` to be part of every variable/member declaration?