C++ examples for STL:set
Storing Objects in Sorted Order
#include <iostream> #include <set> #include <string> using namespace std; int main() {//from www . ja v a 2 s .c om set<string> setStr; string s = "Bill"; setStr.insert(s); s = "S"; setStr.insert(s); s = "R"; setStr.insert(s); s = "H"; setStr.insert(s); for (set<string>::const_iterator p = setStr.begin(); p != setStr.end(); ++p) cout << *p << endl; }