In functional programming, functions are considered first-class objects (you might encounter first-class citizens as well). This means we should treat them as objects rather than a set of instructions. What difference does this make to us? Well, the only thing that is important at this point for a function to be treated as an object is the ability to pass it to other functions. Functions that take other functions as arguments are called higher-order functions.
It's not uncommon for C++ programmers to pass one function into another. Here's how this can be done the old-school way:
typedef void (*PF)(int);void foo(int arg) { // do something with arg}int bar(int arg, PF f){ f(arg); return arg;}bar(42, foo);
In the preceding ...