Skip to content

Instantly share code, notes, and snippets.

@harry830622
Created January 21, 2020 08:49
Show Gist options
  • Select an option

  • Save harry830622/2649dbaf488dba1c44de971804c5ecac to your computer and use it in GitHub Desktop.

Select an option

Save harry830622/2649dbaf488dba1c44de971804c5ecac to your computer and use it in GitHub Desktop.
Create a Functor in C++
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