Assigned Reading:
Handouts (available on-line):
Topics Covered:
STL often uses this mechanism, which they call function objects, for passing functions to STL algorithms instead of passing a function pointer. This mechanism provides greater flexibility than passing a function pointer. For example, in our RandomFunction class, the constructor sets the random seed using the system clock and makes sure that the seed is set only once using the static member seeded.
The sample run shows that we now get a different sequence of 10 words each time we run the program.
Note that the find() member function of set returns an iterator that "points to" the item found. If the item is not in the set, the value of end() is returned: