Hey guys i want to implement a priority queue which contains entries of type 'node'. The code is as follows....
struct node
{
int a;
int b;
};
bool cmp(const node& A,const node& B)
{
return (A.a<B.a) || (A.a==B.a && A.b>B.b);
}
/// main function starts
priority_queue<node,vector<node>, cmp> Y;
But i am not able to compile with error... "type/value mismatch at argument 3 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue"... Can anyone help me out...
The third template parameter of
priority_queue
expects a type (_functor_), not a function. Rather than doing it this way, it's easier to define the comparison operator inside the struct, thenpriority_queue
will see it automatically:If you still want to use the functor way, then you should define the functor class:
excellent... thanks a lot.. Can i get ur facebook id or email id so that i can be in touch with u ... :)
There is a contact option on CodeForces too (send message to user on profile page):P
i have done this but nobody replies :(