CHAPTER7-9.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER7-9.cpp
- #include <deque>
- #include <iostream>
- #if _MSC_VER > 1020 // if VC++ version is > 4.2
- using namespace std; // std c++ libs implemented in std
- #endif
- int main( )
- { deque <int> c1;
- deque <int>::iterator c1_Iter;
- c1.push_back( 10 );
- c1.push_back( 20 );
- c1.push_back( 30 );
- c1_Iter = c1.end( ); //指向c1变量中的最后一个元素的迭代器
- c1_Iter--;
- cout << "The last integer of c1 is " << *c1_Iter << endl;
- c1_Iter--;
- *c1_Iter = 400;
- cout << "The new next-to-last integer of c1 is " << *c1_Iter << endl;
- // If a const iterator had been declared instead with the line:
- // deque <int>::const_iterator c1_Iter;
- // an error would have resulted when inserting the 400
- cout << "The deque is now:";
- for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
- cout << " " << *c1_Iter;
- return 0;
- }