|
|
|
|
Imagine that you wish to write a function in C++ that goes through all the values in an array, and prints out all those values that match certain criteria, where the criteria are specified by calling back a supplied function. The callback function is specified by passing in a pointer to that function. Here's some C++ code that supports this, using callback functions.
The output of this program is: Values > 10 : 37 56 15 92 Values < 20 : 4 -5 8 2 15 In other words, each of the values in the array that matches the condition enforced in each callback function. |
|
This page was last modified on 02 October, 2007 |