没有匹配的函数调用

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函数。