... algorithm
 6   #include <numeric> // accumulate algorithm
 7   #include <functional> // binary_function definition
 8   #include <iterator> // ostream_iterator
 9   using namespace std;
10
11   // binary function adds square of its second argument and the  
12   // running total in its first argument, then returns the sum   
13   int sumSquares(int total, int value) {                         
14      return total + value * value;                               
15   }                                                              
16
17   // Class template SumSquaresClass defines overloaded operator()
18   // that adds the square of its second argument and running     
19   // total in its first argument, then returns sum               
20   template<typename T>
21   class SumSquaresClass ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.