adding functor example

This commit is contained in:
Jidong Xiao
2023-11-20 16:47:40 -05:00
parent 960874cc38
commit 4e0a37792b

View File

@@ -17,11 +17,13 @@ but powerful.
```cpp ```cpp
class my_class_name { class my_class_name {
public: public:
// ... normal class stuff ... // ... normal class stuff ...
my_return_type operator() ( /* my list of args */ ); my_return_type operator() ( /* my list of args */ );
}; };
``` ```
- See and run this simple functor [example](functor.cpp).
## 21.2 Why are Functors Useful? ## 21.2 Why are Functors Useful?
- One example is the default 3rd argument for std::sort. We know that by default STLs sort routines will use - One example is the default 3rd argument for std::sort. We know that by default STLs sort routines will use