## 24.3.3 Function Objects (cont.)

- Predicates often written as function objects
- Generalize `even` to divisible-by-n:

  >     class DivisibleBy {
  >     public:
  >        DivisibleBy(int in);
  >        bool operator()(int x);
  >     private:
  >        int n;
  >     };

  >     DivisibleBy::DivisibleBy(int in) : n(in) {}

  >     inline bool DivisibleBy::operator()(int x)
  >     { return 0 == x % n; }

prev |top |next