guys i am trying to implement priority queue in c++ using stl . my code is given below :
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
class compa
{
public:
bool compar(const int&a,const int& b)const
{
return(a<b);
}
};
int main()
{
int i,k;
priority_queue<int,vector<int>,compa> q;
for(i=0;i<4;i++)
{
cin>>k;
q.push(k);
}
while(!q.empty())
{
k=q.top();
cout<<k<<" ";
q.pop();
}
return 0;
}
i want to implement priority queue to give elements priority in reverse order i.e highest priority to smallest and so on.. please tell me where i am going wrong