I recently switched from java to c++ and am not too familiar with the functions of different c++ data structures.
The code below has a queue, Q
, of Pet
s. I am trying to sort the queue by using the struct cmp
.
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
enum owner { A, B };
class Pet {
public:
int b, e, id;
owner o;
};
struct cmp
{
bool operator()(Pet a, Pet b) const
{
return a.id - b.id;
}
};
int main(){
queue<Pet, cmp> Q;
}
However, the compiler is giving this error:
no type named 'value_type' in 'cmp'
I have tried debugging, looking at other posts, and changing the (Pet a, Pet b)
in cmp
to (int a, int b)
& etc.