class IntSet { private: enum { MAXVALUES = 10 }; int data [MAXVALUES]; int count; // number of values currently in the set bool walkInProgress; int walkPosition; // position of last value returned public: // constructs an empty set. // for really trivial constructors and methods, the complete // implementation is often placed directly in the class definition. IntSet () { count = 0; walkInProgress = false; } // adds a value to the set. returns true on success (space available) // and false on failure (set full) bool add (int value); // removes the specified value from the set. returns // true on success (value existed) and false on failure (value did not exist) bool remove (int value); // returns the number of times that the specified value occurs in the set int countOccurrences (int value) const; // returns the number of values in the set. int size () const { return count; } // These two methods make it possible to "walk through" the values in a // set. The values in the set may be returned in any order. There is no // guarantee that they will be returned in numerical order, in the order in // which they were entered, or any other particular order. "startWalk" may // be called at any time. If returns true on success (value obtained) and // false on failure (set empty). "continueWalk" may only be called if // 1/. the set has not been modified since a walk was // begun by calling startWalk AND // 2/. the last call to startWalk or ContinueWalk returned true // If these conditions are not met, "contiinueWalk" throws a "range_error" // exception. It returns true on success (value obtained) and false on // failure (no more values). bool startWalk (int &value); bool continueWalk (int &value); };