CHAPTER9-4.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER9-4.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( )
- {
- multiset <int> ms1;
- multiset <int>::iterator ms1_Iter;
- multiset <int>::const_iterator ms1_cIter;
- ms1.insert( 1 );
- ms1.insert( 2 );
- ms1.insert( 3 );
- ms1_Iter = ms1.begin( );
- cout << "The first element of ms1 is " << *ms1_Iter << endl;
- ms1_Iter = ms1.begin( );
- ms1.erase( ms1_Iter );
- // The following 2 lines would err as the iterator is const
- // ms1_cIter = ms1.begin( );
- // ms1.erase( ms1_cIter );
- ms1_cIter = ms1.begin( );
- cout << "The first element of ms1 is now " << *ms1_cIter << endl;
- }