我想定义一个用于对对象“ esame”的向量进行排序的运算符,但是我有此错误:
/ * esame.cpp:46:6:错误:'bool esame :: operator <(esame&)const'的原型与'esame'类中的任何内容都不匹配bool esame :: operator <(esame&exam)const ^ ~~~ 〜在esame.cpp:1:0:* / esame.h:20:10包含的文件中:错误:候选者是:bool esame :: operator <(const esame&)const
bool operator<(const esame &) const
//this is the declaration on the header file:
bool operator<(const esame &) const;
//this is implementation on the cpp file:
bool esame::operator<(esame &exam) const
{
if (this->getNome() < exam.getNome()){
return true;
} else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud) c++ ×1