Source of list03.cpp


  1: //list03.cpp

  3: #include <iostream>
  4: #include <iomanip>
  5: #include <string>
  6: #include <list>
  7: using namespace std;

  9: int main()
 10: {
 11:     cout << "\nThis program illustrates the member function max_size() "
 12:         "and shows how the\nmaximum size of a list depends on its "
 13:         "component type.";
 14:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 16:     cout << "\nHere are the maximum sizes of several lists "
 17:         "of different component types:\n\n";

 19:     list<int> lst1;
 20:     list<double> lst2;
 21:     list<bool> lst3;
 22:     list<char> lst4;

 24:     //Just something that takes up a lot of space
 25:     struct BigThing
 26:     {
 27:         double first[10000];
 28:         double second[1000000];
 29:     };
 30:     list<BigThing> lst5;

 32:     cout << "Maximum size of a list<int> ......."
 33:         << setw(11) << lst1.max_size() << "\n"
 34:         << "Maximum size of a list<double> ...."
 35:         << setw(11) << lst2.max_size() << "\n"
 36:         << "Maximum size of a list<bool> ......"
 37:         << setw(11) << lst3.max_size() << "\n"
 38:         << "Maximum size of a list<char> ......"
 39:         << setw(11) << lst4.max_size() << "\n"
 40:         << "Maximum size of a list<BigThing> .."
 41:         << setw(11) << lst5.max_size() << "\n\n";
 42:     cout << "Press Enter to continue ... ";  cin.ignore(80, '\n');
 43: }