create an instance of C++ STL priority_queue from an array


👍 g++ -std=c++11 
   stl_pq_from_array.cpp
👍 ./a.out
6 5 4 

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

int main() {
  int a[]{4,6,5};
  priority_queue<int> pq(a,a+3);
  while (!pq.empty()) {
    cout << pq.top() << ' ';
    pq.pop();
  }
  cout << endl;
}

    

ch 4.6 PRIORITY QUEUES IN THE STANDARD TEMPLATE LIBRARY p152 of