Ok. I'm a beginner and missed that fact that I was missing the open and closed parentheses next to "pop". It's a method. Duh!!! Thanks for reading.
I would like to have a priority_queue of what I would, previously, have thought of as a struct. So, I created class called PqElement. This class has 2 members (an int and a double). I want the priority_queue to be ordered on the double in ascending order (smallest on top).
The error I am getting is on a small function/method in my class PriorityQueue.
Can someone help me figure this out and resolve it?
The error is:
Error C3867 'std::priority_queue<PqElement,std::vector<PqElement,std::allocator<PqElement>>::pop':non-standard syntax; use '&' to create a pointer to member
class PqElement {
public:
//===================
// Constructor
//===================
PqElement(int n = 0, double nv = 0.0) : pqN(n), pqNV(nv) {}
//===================
// Function: set_pqN
// Set Node ID (index) in pqelement
//===================
void set_pqN(int n) {
pqN = n;
}
//===================
// Function: set_pqNV
// Set Node Value in pqelement
//===================
void set_pqNV(double nv) {
pqNV = nv;
}
//===================
// Function: get_pqN
// Get Node ID (index) from pqelement
//===================
int get_pqN() { return pqN; }
//===================
// Function: get_pqNV
// Get Node Value from pqelement
//===================
double get_pqNV() { return pqNV; }
private:
int pqN; // Node ID which can be used as the index into a number of vectors
double pqNV; // Node Value (current distance to the node)
}; // end Class PqElement
The ComparePQE class:
1 2 3 4 5 6 7 8 9 10
class ComparePQE {
public:
// Operator override
booloperator()(PqElement& lhs, PqElement& rhs) {
double lnv = lhs.get_pqNV();
double rnv = rhs.get_pqNV();
return lnv > rnv;
}
}; // end Class ComparePQE
Here is the declaration of the priority_queue in my PriorityQueue class: