Source of pair2.cpp


  1: //pair2.cpp

  3: #include <iostream>
  4: #include <iomanip>
  5: #include <utility>
  6: using namespace std;

  8: int main()
  9: {
 10:     cout << "\nThis program illustrates comparison of pair objects.";
 11:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 13:     cout << "\nFirst we create the following pair objects:"
 14:         "\npair<char, int> pair1('A', 10);"
 15:         "\npair<char, int> pair2('B', 5);"
 16:         "\npair<char, int> pair3('B', 10);"
 17:         "\npair<char, int> pair4('B', 10);";
 18:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 20:     pair<char, int> pair1('A', 10);
 21:     pair<char, int> pair2('B', 5);
 22:     pair<char, int> pair3('B', 10);
 23:     pair<char, int> pair4('B', 10);
 24:     cout << "\nNext we compute the values of some comparisons.";
 25:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 27:     cout << "\npair1 <   pair2 = " << boolalpha << (pair1 < pair2);
 28:     cout << "\npair1 >=  pair2 = " << boolalpha << (pair1 >= pair2);
 29:     cout << "\npair2 <   pair3 = " << boolalpha << (pair2 < pair3);
 30:     cout << "\npair2 >=  pair3 = " << boolalpha << (pair2 >= pair3);
 31:     cout << "\npair3 ==  pair4 = " << boolalpha << (pair3 == pair4);
 32:     cout << "\npair3 !=  pair4 = " << boolalpha << (pair3 != pair4);
 33:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');
 34: }