E
eric.boissard
Hello,
I managed to implement the AStar algorithm, however I have some trouble
using the priority queue, and the 'compare' function.
Here is my 'Waypoint.h' header file:
class Waypoint
{
public:
int node_id;
float x,y,z;
float g,h,f;
int nConnections;
std::vector<int> connects;
Waypoint *parent;
bool onClosed;
bool onOpen;
};
//Comparison function used in the priority_queue
struct compare : binary_function<Waypoint *, Waypoint *, bool>
{
// Other stuff...
bool operator()(const Waypoint *x, const Waypoint *y) const {
return x->f > y->f;
}
};
My problem is as soon as I try to include 'Waypoint.h' in any .cpp
file, I have some errors:
error C2504: 'binary_function' : base class undefined
error C2143: syntax error : missing ',' before '<'
(I started to have this problem when I decided to split and reorganise
my files)
Anyone can help me please, I am just starting using stl priority
queues. I will be honest, I cut/paste this part from an example but I
really want to know how this comparison function exactly works.
Thanks a lot for your help
Eric
I managed to implement the AStar algorithm, however I have some trouble
using the priority queue, and the 'compare' function.
Here is my 'Waypoint.h' header file:
class Waypoint
{
public:
int node_id;
float x,y,z;
float g,h,f;
int nConnections;
std::vector<int> connects;
Waypoint *parent;
bool onClosed;
bool onOpen;
};
//Comparison function used in the priority_queue
struct compare : binary_function<Waypoint *, Waypoint *, bool>
{
// Other stuff...
bool operator()(const Waypoint *x, const Waypoint *y) const {
return x->f > y->f;
}
};
My problem is as soon as I try to include 'Waypoint.h' in any .cpp
file, I have some errors:
error C2504: 'binary_function' : base class undefined
error C2143: syntax error : missing ',' before '<'
(I started to have this problem when I decided to split and reorganise
my files)
Anyone can help me please, I am just starting using stl priority
queues. I will be honest, I cut/paste this part from an example but I
really want to know how this comparison function exactly works.
Thanks a lot for your help
Eric