[cs23021] set manipulation example

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Nov 29 19:04:31 EST 2007


CS1 students,

A set manipulation example that would be useful for the third
part of your project #6 is given here

http://www.cs.kent.edu/~mikhail/classes/ioop.f07/Examples/STL/Sets/example.cpp

There are extensive comments in the example code, however the main
points are as follows:

* to do set manipulation you need include <algorithm> header file.
* to allow templated set manipulation functions (such as
  set_union to create a resultant set, you need to declare so called
  insert_iterator. It work sort of like a write-head on a tape - only
  one way and no rewinding.
  The syntax of the definition and use of the insert_iterator are
  shown in the example
* the declaration of the insert_iterator, watch out the space between 
  double angle brackets: it has to be as follows: > >
  If there is no space: >> 
  the compiler mistakes it for an extraction operator and gets
  confused.

Thanks,
-- 
Mikhail


More information about the cs23021 mailing list