0
이중 매개 변수 이진 검색 트리를 개발했으며이를 사전 적용에 적용하려고합니다. 그러나 트리 내에서 내 find 함수는 필자가해야만 하듯이 작동하지만 사전 클래스의 내부에서 호출 할 때 컴파일러 오류 "예상 기본 표현식이 '>'토큰이됩니다."라는 오류가 발생합니다. 아무도 무슨 일이 일어나고 있는지 이해할 수있게 도와 줄 수 있습니까? 다른 파일에서 함수를 호출하는 데 익숙하지 않습니다.다른 헤더 파일에서 함수를 호출 할 때 오류 발생 (C++)
이것은 bst.h
V & find (K key)
{
TreeNode<K,V> *traverseFind;
traverseFind = root;
unsigned int compareTraverseToHeight = 0;
while (compareTraverseToHeight < heightCount)
{
if (traverseFind == NULL) // Fallen off
{
keyFinder = 0;
break;
}
else if (key == traverseFind->key)// Found key
{
keyFinder = 1;
break;
}
else if (key < traverseFind->key)
{ .
traverseFind = traverseFind->left;
}
else
{
traverseFind = traverseFind->right;
}
compareTraverseToHeight++;
} // end of loop
if(keyFinder ==0)
{
throw key_not_found_exception();
}
cout<<"RETURNED "<<traverseFind->value<<endl;
return traverseFind->value;
}
의 내부 이진 검색 트리에서 나의 찾기 기능입니다 그리고 사전 :
#include bst.h
template <class K, class V> class Dictionary
{
public:
BinarySearchTree<K,V> wiktionary;
Dictionary()
{
}
~Dictionary()
{
}
V & find (K key)
{
return(wiktionary.find(<V>)); //this is the issue
}
private:
};
#endif
그리고 메인에서 응용 프로그램 :
int main()
{
Dictionary<string, int> d;
int val = d.find("abc");
if (val != 15)
throw dictionary_tester_exception(__FILE__, __LINE__);
return 0;
}
사용'wiktionary.find'(키) :/ –
오 와우, 나는 그것을 잡을하지 않았다 방법을 모르겠어요. 이 대답을하면 받아 들일거야, 고마워. – Mock