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);
}
}
Tehát ez az én keresési funkció az én BST osztály egy T csomópont. x az adataik keresett a fa, len csak az összeg a csomópontok azt utazni, hogy dolgozzon ki a megfelelő csomópontot, ha létezik. Még nem implented hogy még, én csak fokozatosan fejlődő megbízásom. Hívom azt csinál ez:
if(t.search(v[1], len) == true)
cout << endl << true;
v csak egy vektor kellett létrehozni, hogy hasonlítsa össze, és így ez csak ellátása céljából az int. A hiba kapok:
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]
Szóval nem tudom, mit csinálok rosszul, vagy ha csinálok rosszul.













