| So that what happens. And, I've been wondering, what does this
| declaration mean:
|
| void fn(void(*)(int&,int&),int&,int&);
Obviously, fn is a function. It is declared on the form
type name(arg-list)
with type = void, and arg-list consists of
1: void(*)(int&,int&)
2: int&
3: int&
The two last arguments are the easiest ones. They must be references to
ints. The first type should be memorized:
void (*)(int&, int&)
means a pointer (*) to a function (int&, int&) returning void. One
could also have used the form:
void (*f)(int&, int&)
This form is declaring the expression (*f) to be a function taking
(int&, int&), and returning void, and thus f must be a pointer to this.
Because those smart ones, who created the standard, found it was smart
to allow someone call a function pointer. one can call the function
pointed to by f, with the expression f(a, b), but you can still write
(*f)(a, b).
| And exactly why do you use callback functions?
Callbacks are very practical in some contexts. A common application is
GUI programming, where callbacks is used for `call this function if and
when the user presses this button'. This allows for flexible GUI
libraries. The standard library uses callbacks too. The routine
for_each, for example, calls a function for every argument in a
sequence.