CHAPTER8-22.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER8-22.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, c2, c3;
- list <int>::iterator c1_Iter;
- c1.push_back( 1 );
- c1.push_back( 2 );
- c1.push_back( 3 );
- c2.push_back( 10 );
- c2.push_back( 20 );
- c3.push_back( 100 );
- cout << "The original list c1 is:";
- for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
- cout << " " << *c1_Iter;
- cout << endl;
- c1.swap( c2 );
- cout << "After swapping with c2, list c1 is:";
- for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
- cout << " " << *c1_Iter;
- cout << endl;
- swap( c1,c3 );
- cout << "After swapping with c3, list c1 is:";
- for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
- cout << " " << *c1_Iter;
- cout << endl;
- return 0;
- }