Created
January 21, 2020 08:49
-
-
Save harry830622/2649dbaf488dba1c44de971804c5ecac to your computer and use it in GitHub Desktop.
Create a Functor in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Functor { | |
| public: | |
| Functor() :sum_(0) {} | |
| int operator()(int n) { | |
| sum_ += n; | |
| return sum_; | |
| } | |
| private: | |
| int sum_; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment