CHAPTER8-35.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER8-35.cpp
- #include <list>
- #include <iostream>
- #if _MSC_VER > 1020 // if VC++ version is > 4.2
- using namespace std; // std c++ libs implemented in std
- #endif
- int main( )
- {
- using namespace std;
- list <int> c1;
- list <int>::iterator c1_Iter, c2_Iter;
- c1.push_back( 5 );
- c1.push_back( 100 );
- c1.push_back( 5 );
- c1.push_back( 200 );
- c1.push_back( 5 );
- c1.push_back( 300 );
- cout << "The initial list is c1 =";
- for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
- cout << " " << *c1_Iter;
- cout << endl;
- list <int> c2 = c1;
- c2.remove( 5 );
- cout << "After removing elements with value 5, the list becomes c2 =";
- for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
- cout << " " << *c2_Iter;
- cout << endl;
- return 0;
- }