【发布时间】:2019-03-29 08:37:57
【问题描述】:
我想定义一个运算符来对对象向量“esame”进行排序,但我有这个错误:
/* esame.cpp:46:6: 错误:'bool 的原型 esame::operator
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;
}
}
【问题讨论】:
-
与错误无关,但
this->getNome() < exam.getNome()的结果已经是bool。你不需要if
标签: c++