The first-class function is just a normal class. We can treat the first-class function like any other data type. However, in the language that supports the first-class function, we can do the following tasks without invoking the compiler recursively:
- Passing a function as another function's parameter
- Assigning functions to variables
- Storing functions in collections
- Creating new functions from the existing functions at runtime
Fortunately, C++ can be used to solve the preceding tasks. We will discuss it in depth in the following topics.