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);
}
}
Quindi questa è la mia funzione di ricerca per la mia classe BST con un nodo T. x è i dati da ricercare all'interno dell'albero, len è solo la quantità di nodi che deve percorrere per venire con il corrispondente nodo se esiste. Non ho implented che ancora, sto solo in modo incrementale sviluppare il mio incarico. Sto chiamando in questo modo:
if(t.search(v[1], len) == true)
cout << endl << true;
v è solo un vettore ho dovuto creare per confrontarlo, e così questo è solo la fornitura con un int. L'errore che sto ricevendo:
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]
Quindi io non sono sicuro di quello che sto facendo male o dove sto facendo male.













