I need a std::set<std::pair<int,NodeA>>
. So i need to overload the < operator of NodeA. I did it, but it doesn't work.
void matriceLab::aStar(int* matX,const int x, const int y, const int endX,const int endY){
std::set<std::pair<int,NodeA>> nodi;
allocaNodi(nodi,matX,x,y,endX,endY);
}
void matriceLab::allocaNodi(std::set<std::pair<int,NodeA>>& nodi, int* matX,const int x, const int y,const int endX,const int endY){
for(int i = 0; i < x; i++){
for(int j = 0; j < y; j = j + 2){
NodeA nodo(i,j,endX,endY);
std::pair <int,NodeA> pair1(i + j * x, nodo);
nodi.insert(pair1);
}
}
}
class NodeA
{
//...
bool operator<(const NodeA& a){
if(posX < a.posX){
return true;
}else{
return false;
}
}
//...
}
C:\TDM-GCC-32\lib\gcc\mingw32\5.1.0\include\c++\bits\stl_pair.h|222|error: no match for 'operator<' (operand types are 'const NodeA' and 'const NodeA')|
C:\Users\cristina\Desktop\università pdf\Laboratorio di Programmazione\progetti c++_SFML_openGL\SFML-2019-4-Grid\NodeA.h|24|note: candidate: bool NodeA::operator<(const NodeA&) << near match>>