CHAPTER9-3.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER9-3.cpp
- #include <set>
- #include <iostream>
- #if _MSC_VER > 1020 // if VC++ version is > 4.2
- using namespace std; // std c++ libs implemented in std
- #endif
- int main( )
- {
- set <int> s1;
- set <int>::iterator s1_Iter;
- set <int>::const_iterator s1_cIter;
- s1.insert( 1 );
- s1.insert( 2 );
- s1.insert( 3 );
- s1_Iter = s1.begin( );
- cout << "The first element of s1 is " << *s1_Iter << endl;
- s1_Iter = s1.begin( );
- s1.erase( s1_Iter );
- // The following 2 lines would err because the iterator is const
- // s1_cIter = s1.begin( );
- // s1.erase( s1_cIter );
- s1_cIter = s1.begin( );
- cout << "The first element of s1 is now " << *s1_cIter << endl;
- }