0
我開發了一個雙參數二叉搜索樹,現在正試圖將其應用於創建字典。然而,當我在字典類中嘗試調用它時,我發現編譯器錯誤「在'>'標記之前期望初級表達式」。任何人都可以幫助我瞭解發生了什麼問題嗎?我不太熟悉試圖從其他文件調用函數。嘗試從另一個頭文件調用函數時出現錯誤(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(密鑰)':/ – 2014-12-03 17:59:02
哇哦,不知道我怎麼沒趕上。讓這個答案,我會接受它,謝謝。 – Mock 2014-12-03 18:08:18