Similarly to a pass function as a parameter:
* Want some action when selecting a graphical object.
Please call this functionwhen the user presses this
button
* Functions as objects. As we will see later, C++ classes
are essentially structures which include "member
functions" (operations on the object). In C much of the
equivalent can be achieved using pointers to functions.
* System calls to sort or search, where you need to tell the
system how to compare data types
All sorting functions have at their heart an evaluation
function that is used to rank two elements.
The algorithm is independent of the details of this
comparison, so why not write a generic sort function and
pass the comparison routine as a parameter?
|