没有匹配的函数调用
No matching function call
本文关键字:函数调用 更新时间:2023-10-16
In member function ‘void reviewData::showMaxReviews() const’:
reviewData.cpp:130:46: error: no matching function for call to
‘avlTree<std::basic_string<char> >::Findmax(std::string&, double&, unsigned int&) const’
purchase.Findmax( name, points, counter);
reviewData.cpp:130:46: note: candidates are:
In file included from reviewData.h:6:0,
from reviewData.cpp:5:
avlTree.h:132:7: note: bool avlTree<myType>::Findmax(std::string&, double&, unsigned int&) [with myType = std::basic_string<char>;
std::string = std::basic_string<char>] <near match>
bool avlTree<myType>::Findmax( string & name, double & points, unsigned int & count )
bool avlTree<myType>::Findmax( string &name, double &points, unsigned int &count )
// This is how product is declared in reviewdata.h
avlTree<string> purchase;
void reviewData::showMaxReviews() const
string name;
double points = 0;
unsigned int counter = 0;
bool cool;
purchase.Findmax( name, points, counter);
我无法弄清楚这里到底是什么问题,因为我认为我传递了正确的参数,但我仍然无法编译。我怀疑这与通过引用有关,但我不确定。
showMaxReviews
函数被标记为const
,这意味着它不能修改reviewData
类的任何成员变量。这意味着它不能调用函数,它this
或成员对象,在 不const
.
findMaxReview
函数没有标记为const
,因此不能调用。如您所见,如果您阅读错误消息,编译器正在尝试调用const
函数。
相关文章:
- 函数调用中参数的顺序重要吗
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 变量没有改变?通过向量的函数调用
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 是否有C++编译器选项允许激进地删除所有函数调用,并将参数传递给具有空体的函数
- 我知道函数调用中存在歧义.有没有办法调用foo()函数
- 模板函数调用
- 获取从C++中同一类中的构造函数调用的方法返回的值
- 析构函数调用
- 成员函数调用和C++对象模型
- 使用共享指针的函数调用,其对象应为 const
- C++:编译时检查匹配的函数调用对?
- 函数调用C++中的参数太少
- 来自 DLL 的函数调用 [表观调用的括号前面的表达式必须具有(指向-)函数类型]
- 返回指向对象的指针的函数调用是否为 prvalue?
- C++ 如何重载 [] 运算符并进行函数调用
- 代码的效率. 转到和函数调用
- 是同一作用域的函数部分中的函数调用
- 如何封装一个函数,以便它只能由同一类中的一个其他函数调用?
- 类型擦除的std::function与虚拟函数调用的开销