我正在尝试重载“<”运算符,以便可以在项目中使用 std::map。类定义中的原型是这样的:bool operator<(const Vertex&);
,函数体是这样的:
bool Vertex::operator <(const Vertex& other){
//incomplete, just a placeholder for now
if(px != other.px){
return px < other.px;
}
return false;
}
我得到的错误是:/usr/include/c++/4.7/bits/stl_function.h:237:22: error: passing ‘const Vertex’ as ‘this’ argument of ‘const bool Vertex::operator<(Vertex)’ discards qualifiers [-fpermissive]