没有匹配的函数调用

时间:2017-10-08 04:24:50

标签: c++

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);

我无法弄清楚这里究竟是什么问题,因为我认为我传递了正确的参数但是我仍然无法编译。我怀疑这与通过引用传递有关,但我不确定。

1 个答案:

答案 0 :(得分:0)

showMaxReviews函数标记为const,这意味着它无法修改reviewData类的任何成员变量。这意味着它无法调用函数this或成员对象,而不是const

findMaxReview函数标记为const,因此无法调用。如您所见,如果您阅读了错误消息,则编译器正在尝试调用const函数。