小编Fra*_*tis的帖子

为什么我有这个错误使操作员超载?

我想定义一个用于对对象“ 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
推荐指数
1
解决办法
62
查看次数

标签 统计

c++ ×1