错误:候选函数不可行:'this'参数具有类型 'const' 但方法未标记为 const
Error: candidate function not viable: 'this' argument has type 'const' but method is not marked const
我已经遇到了一些试图编译项目的问题。它一直给我留言:"候选函数不可行:'此'参数具有类型为'const',但方法不是标记const"。以下是此错误出现的函数。
bool operator<(const node& x) const{
if(name < x.name){
return true;
} else{
return false;
}
}
bool operator==(const node& x){
if(name == x.name){
return true;
} else{
return false;
}
}
如果有人有任何想法或知道我使用const的问题,我将非常感激。
更改以下内容:
bool operator==(const node& x) {
:
bool operator==(const node& x) const {
为了标记您的其他功能const。
相关文章:
- 将 const 转换为 const char* 无效,我该如何解决?使用 gcc7 时失败
- 为什么我需要将默认引用参数定义为 const 以便为其分配一个左值?
- 编译器可以静默地从 const 转换为 const 和,反之亦然吗?
- 从 Object<const T> 转换为 Object<t>
- 错误:无法将const字符串转换为参数1的const char*为size_t strlen(const char*)
- 将 const 传递为这样时出错
- 为什么在设置类成员时会自动从 const 转换为 non-const 并发生?
- 同时向下投递并从 const 转换为非 const
- 没有匹配的操作数[template]/无法从Type const*转换为Type
- static const转换为c++共享库中的对象.是进程间共享的吗?
- 无法从 *const 转换为 &in += 运算符
- C2664 无法在 Qt C++ 中将参数 1 从用户 *const 转换为用户
- C++:以"const pointer"为成员的列表与以"pointer to const"为成员的列表
- 将const复制为char*
- 错误:将(const A)传递为(this)
- const转换为非const或非const转换为const
- C++11:无法将参数从'T *const'转换为'T *&&'
- 复制构造函数将const转换为非const
- c++将非const引用为temporary:是否合法?
- 对于obj(obj*const a=obj const*b),int*const a=int const*b是否为tru