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);
}
}
これは、T ノードを持つ BST クラスの検索関数です。x はツリー内で検索されるデータです。len は、一致するノードが存在する場合にそれを見つけるために移動しなければならないノードの数です。私はまだそれを実装していません。私は自分の課題を段階的に開発しているだけです。私はこれを行うことでそれを呼び出しています:
if(t.search(v[1], len) == true)
cout << endl << "true";
v は、比較するために作成しなければならなかった単なるベクトルなので、これは単に int を指定するだけです。私が得ているエラー:
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]
そのため、自分が何を間違っているのか、どこが間違っているのかわかりません。