#include <iostream>
#include <unordered_set>
#include <set>
using namespace std;
struct Cube {
int x;
int y;
int number;
bool canRemove;
Cube(int x, int y, int number) : x(x), y(y), number(number) {}
bool operator == (const Cube &c) const {
return true;
}
};
int main () {
int m;
cin >> m;
unordered_set<Cube> s;
//unordered_set<Cube> s1;
//unordered_set<Cube> s2;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
s.insert(Cube(x, y, i));
}
cout << s.size() << endl;
return 0;
}
For my understanding: I should overload < for set, because it is a binary search tree. I should overload == for unordered_set, because it is a hash table. Please correct me if I am wrong.
Question:
1 the code can't compile, please help me fix it.
2 for this line:
bool operator < (const Cube &c) const {
if I delete the second const. It also can't compile for set why I need the second const? why I can't overload < this way?
bool operator < ( Cube &c) {
}