a max priority queue of kids


👍 g++ -std=c++11 stl_pq_kids.cpp
👍 ./a.out
pqName1:(Ryan,11) (Peter,14) (Felix,12)

👍 cat stl_pq_kids.cpp 
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Kid {
  string name;
  int age;
  bool operator<(const Kid &k) const
    { return name < k.name; }
};

ostream& operator<<(ostream &o,
                    const Kid &k){
  o << "(" << k.name << ","
    << k.age << ")";
  return o;
}

int main() {
  Kid kids[]{Kid{"Felix", 12},
             Kid{"Peter", 14},
             Kid{"Ryan",  11}};
  priority_queue<Kid> pqName1(kids, 
                              kids+3);
  cout << "pqName1:";
  while (!pqName1.empty()) {
    cout << pqName1.top() << ' ';
    pqName1.pop();
  }
  cout << endl;
}


    

ch 4.6 PRIORITY QUEUES IN THE STANDARD TEMPLATE LIBRARY p152 of