I am trying to use priority queue with custom classen. My class is node(name, .., .., distance, ...) but when in try to push a node into the queue i get a error.
node a = node("a",{}, 0, &a); node b = node("b",{}, INT_MAX, &a); node c = node("c",{}, INT_MAX, &a); node d = node("d", {}, INT_MAX, &a); node e = node("e", {}, INT_MAX, &a);
edge a1 = edge(&a, &b,10); edge a2 = edge(&a, &c, 1); edge a3 = edge(&a, &d, 4);
edge b1 = edge(&b, &d, 3); edge b2 = edge(&b, &e, 3);
edge c1 = edge(&c, &d, 2);
edge d1 = edge(&d, &e, 10); edge d2 = edge(&d, &b, 3);
a.edges.push_back(&a1); a.edges.push_back(&a2); a.edges.push_back(&a3);
b.edges.push_back(&b1); b.edges.push_back(&b2);
c.edges.push_back(&c1);
d.edges.push_back(&d1); d.edges.push_back(&d2);
graph g = graph(
{&a, &b, &c, &d, &e},
{&a1,&a2,&a3,&b1,&b2,&c1,&d1,&d2}
);
node* start = &a;
node* end = &e;
std::vector<node*> eval = {start};
std::vector<node*> test = {&a, &b, &c, &d};
node* shortestNode;
std::priority_queue<node> q;
for(auto i : test)(
q.push(i)
)
What I have tried:
I have tried "copy paste" operator from the internet but none have been usefull.
The error i get is :
no instance of overloaded function "std::priority_queue<_Tp, _Sequence, _Compare>::push [with _Tp=node, _Sequence=std::vector<node, std::allocator<node>>, _Compare=std::less<node>]" matches the argument listC/C++(304)
main.cpp(37, 11): argument types are: (node *)
main.cpp(37, 11): object type is: std::priority_queue<node, std::vector<node, std::allocator<node>>, std::less<node>>