I am facing "binary '<': no operator found which takes a left-hand operand of type 'const Baloons' (or there is no acceptable conversion)" error and I cannot find any solution?
I would also like to ask how can I order the priority queue by baloon.end?
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
class Baloons
{
public:
float start;
float end;
public:
Baloons() {}
Baloons(float start, float end) : start{ start }, end{ end } {}
};
int main()
{
Baloons baloon1(1, 5);
Baloons baloon2(4, 7);
Baloons baloon3(6, 9);
Baloons baloon4(11, 12);
std::priority_queue<Baloons> myBaloons;
myBaloons.push(baloon1);
myBaloons.push(baloon2);
myBaloons.push(baloon3);
myBaloons.push(baloon4);
while (!myBaloons.empty())
{
Baloons b = myBaloons.top();
cout << b.start << " -> " << b.end << " ";
myBaloons.pop();
}
system("pause");
return 0;
}