CHAPTER8-12.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
源码类别:

STL

开发平台:

C/C++

  1. //文件名:CHAPTER8-12.cpp
  2. #include <iostream>
  3. #include <list>
  4. #if _MSC_VER > 1020   // if VC++ version is > 4.2
  5.    using namespace std;  // std c++ libs implemented in std
  6. #endif
  7. int main( )
  8. {  list <int> c1;
  9.    c1.push_back( 10 );
  10.    c1.push_back( 20 );
  11.    c1.push_back( 30 );
  12.    c1.resize( 4,40 );
  13.    cout << "The size of c1 is " << c1.size( ) << endl;
  14.    cout << "The value of the last element is " << c1.back( ) << endl;
  15.    c1.resize( 5 );
  16.    cout << "The size of c1 is now " << c1.size( ) << endl;
  17.    cout << "The value of the last element is now " << c1.back( ) << endl;
  18.    c1.resize( 2 );
  19.    cout << "The reduced size of c1 is: " << c1.size( ) << endl;
  20.    cout << "The value of the last element is now " << c1.back( ) << endl;
  21. }