template <class T>
bool BST<T>::search(const T& x, int& len) const
{
return search(BT<T>::root, x);
}
template <class T>
bool BST<T>::search(struct Node<T>*& root, const T& x)
{
if (root == NULL)
return false;
else
{
if (root->data == x)
return true;
else if(root->data < x)
search(root->left, x);
else
search(root->right, x);
}
}
Więc to jest moja funkcja wyszukiwania dla mojej klasy BST z węzła T. x to dane są wyszukiwane w drzewie, len jest właśnie ilość węzłów musi podróżować wymyślić węzła pasującego jeśli istnieje. Nie implented że jeszcze, ja tylko stopniowo rozwija moje zadanie. Wołam go w ten sposób:
if(t.search(v[1], len) == true)
cout << endl << true;
v jest wektorem prostu musiałem stworzyć porównać go, a więc jest to po prostu dostarczanie go z wew. Błąd Dostaję:
BST.h: In member function âbool BST<T>::search(const T&, int&) const [with T = int]â:
prog5.cc:24: instantiated from here
BST.h:78: error: no matching function for call to âBST<int>::search(Node<int>* const&, const int&) constâ
BST.h:76: note: candidates are: bool BST<T>::search(const T&, int&) const [with T = int]
BST.h:83: note: bool BST<T>::search(Node<T>*&, const T&) [with T = int]
Więc nie jestem pewien, co robię źle lub gdy robię źle.













