Creating Min Heap from STL Priority Queue
c++, min-heap, priority-queue
Solution
The third template parameter must be a binary functor taking teo `Plane*`. Your `Plane` class does not provide that.
You need something of the form
struct CompPlanePtrs
{
bool operator()(const Plane* lhs, const Plane* rhs) const {
return lhs->fuel > rhs->fuel ;
}
};
Problem
I am creating a min heap from stl priority queue. Here is my class which I am using. ``` class Plane { private : int id ; int fuel ; public: Plane():id(0), fuel(0){} Plane(const int _id, const int _fuel):id(_id), fuel(_fuel) {} bool operator > (const Plane &obj) { return ( this->fuel > obj.fuel ? true : false ) ; } ``` } ; In main I instantiate an object thus. ``` priority_queue<Plane*, vector<Plane*>, Plane> pq1 ; pq1.push(new Plane(0, 0)) ; ``` I am getting an error from `xutility` which I am unable to understand. d:\microsoft visual studio 10.0\vc\include\xutility(674): error C2064: term does not evaluate to a function taking 2 arguments Any help to its solution would be appreciated.