CHAPTER8-15.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER8-15.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;
- list <int>::const_iterator c1_cIter;
- c1.push_back( 1 );
- c1.push_back( 2 );
- c1_Iter = c1.begin( );
- cout << "The first element of c1 is " << *c1_Iter << endl;
- *c1_Iter = 20;
- c1_Iter = c1.begin( );
- cout << "The first element of c1 is now " << *c1_Iter << endl;
- // The following line would be an error because iterator is const
- // *c1_cIter = 200;
- return 0;
- }