Passing a function as a parameter

As we discussed in Chapter 2, Manipulating Functions in Functional Programming, we can rewrite the function to be a first-class function, which means we can pass a function to another function. We will simplify the definition of all the four methods we have in the Step01 code, then we will call the function by passing it to another method named GetActiveCustomerByFunctionField(). We will also create a new method named GetActiveCustomerByField() to select the correct method we should run. The definition of the Customer class is now like the following Customer.h code:

    /* Customer.h - Step02 */    #ifndef __CUSTOMER_H__    #define __CUSTOMER_H__    #include <string>    #include <vector>    #include <functional> class Customer ...

Get Learning C++ Functional Programming 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.