Function object: Difference between revisions

Content deleted Content added
In C and C++: Show the function object being called
In C and C++: The first example is also valid C++
Line 24:
 
== In C and C++ ==
Consider the example of a sorting routine that uses a callback function to define an ordering relation between a pair of items. The following C/C++ program uses function pointers:
<!-- NOTE: For the compareInts() implementation below, see http://stackoverflow.com/a/10997428/1629102 for an explanation of why the more simple (int) a - (int) b would not work in all cases. -->
<syntaxhighlight lang="c">