## 24.3.3 Function Objects (cont.)

- Use when each invocation must remember state set by earlier invocation
- To produce a sequence:

  >     class SequenceGenerator {
  >     public:
  >           // Can set starting value
  >        SequenceGenerator(int sv);
  >        int operator()();
  >     private:
  >        int current;
  >     };

  >     SequenceGenerator::SequenceGenerator(int sv)
  >     { current = sv; }

prev |top |next