Is it possible to create a function which takes a pointer to another function? How does the prototype of such a function look like?
typedef int (*func)(float, char);
int something_that_takes_a_func(func f) { return f(3.14, 3); }
int foo(float a, char b) { return a - b; }
std::cout << something_that_takes_a_func(&foo) << "\n";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With