/////////////////////////////////////////////////////////////// // set1.cpp - demonstrate container basics // // // // Jim Fawcett, modified 4/5/98 // /////////////////////////////////////////////////////////////// // disable truncation warnings #pragma warning( disable : 4786 ) // include STL containers and services #include #include #include ///////////////////////////////////////////////////////////// // #include // // STL containers declare their own simple iterators so, // // you won't need this unless you are doing fancy stuff // ///////////////////////////////////////////////////////////// #include using namespace std; void main(int argc, char *argv[]) { ///////////////////////////////////////////////////////////// // vector is an indexable, expandable collection of items // ///////////////////////////////////////////////////////////// vector vos; int i; for(i=1; i::iterator vi; for(vi = vos.begin(); vi != vos.end(); vi++) cout << " " << *vi << endl; // //////////////////////////////////////////// // set is an ordered collection of items // //////////////////////////////////////////// set sos; for(i=1; i::iterator si; for(si = sos.begin(); si != sos.end(); si++) cout << " " << *si << endl; cout << "\nlist of command line arguments in " << "reverse lexographic order:\n"; set::reverse_iterator rsi; for(rsi = sos.rbegin(); rsi != sos.rend(); rsi++) cout << " " << *rsi << endl; }