compiler error, no matching function, what is it telling me?

This is the error I get:
bst.hpp:9: error: no matching function for call to âBST<int>::findStartingAtNode(const int&, BNode<int>* const&) constâ
bst.hpp:14: note: candidates are: bool BST<T>::findStartingAtNode(const T&, BNode<T>*&) [with T = int]

This is the associated code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
template <class T>
bool BST<T>::find(const T& x) const
{
  return findStartingAtNode(x, BinaryTree<T>::m_root);

}

template <class T>
bool BST<T>::findStartingAtNode(const T& x, BNode<T>*& nodePtr)
{
   if (nodePtr==NULL)
     return false;
   if (nodePtr->m_data == x)
     return true;
   if (x < nodePtr->m_data)
     findStartingAtNode(x, nodePtr->m_left);
   else
     findStartingAtNode(x, nodePtr->m_right);
}


and these are the prototypes:
1
2
3
  bool find(const T& x) const;
  
  bool findStartingAtNode(const T& x, BNode<T>*& nodePtr);



I dont see the problem?
I'm trying to implement the find function for a binary search tree, all it does is return true if the value exists, false otherwise.
Last edited on
I think that the problem is that you are trying to call a non-const member function from a const member-function of the same class.
Topic archived. No new replies allowed.