C2678 binary '<': no operator found which takes a left-hand operand of type 'const node'

Hello,

I am trying to fix my program, but i keep getting the error in the title. This is the entire error.

Severity Code Description Project File Line Suppression State
Error C2678 binary '<': no operator found which takes a left-hand operand of type 'const node' (or there is no acceptable conversion) basicgraph c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstddef 239

My code is kind of long so i put it into a paste bin. I think the problem is happening is within the dijkstraBFS function. Specifically with my priority_queue<node> queue. I read something that said I needed to overload < within the struct, but I was unable to get it working. Any help would be greatly appreciated.

https://pastebin.com/15r84Qwt
1
2
3
4
5
6
7
8
9
10
11
12
13
struct node
{
    int index = 0 ;
    int value = 0 ;
    int bestValue = 0 ;

    bool operator < ( const node& rhs ) const // must be const-correct
    {
        // return true if, in a sorted sequence, the node *this should appear before the node rhs 
        // for example:
        return this->value < rhs.value ; // ordered on ascending value 
    }
};
wow thank you!
Topic archived. No new replies allowed.