-3
我有一個函數的代碼,其目的是解密由字符串r,0和1給出的消息。這個想法是我有一個BST,並且基於我的r 0和1的字符串,我將能夠找到我要查找的特定數據的路徑。模板BST方法的返回值問題
我根本找不出要返回什麼來匹配函數的返回值,並從我正在尋找的函數中獲取信息!這裏是教授給的幫助...
/*The decrypt() method takes an encrypted string (or path through the tree)
in the form provided by encrypt(). It should return a pointer to the
associated string for the given path (or NULL if the path is invalid).*/
任何人都可以幫助我通過如何返回正確的變量類型和值,並解釋原因嗎?謝謝! (下面的代碼)
template<class Base>
const Base * EncryptionTree<Base>::decrypt(const string & path) const{
const BSTNode<Base>* temp = root;
bool flag = false;
for (int i = 0; i < path.size(); i++) {
switch (path[i]) {
case 'r':
if (temp != NULL) {
temp = root;
}
else {
flag = true;
}
break;
case '0':
if (temp->getLeft() != NULL) {
temp = temp->getLeft();
}
else {
flag = true;
}
break;
case '1':
if (temp->getRight() != NULL) {
temp = temp->getRight();
}
else {
flag = true;
}
break;
}
}
return ?????;
}
我試圖返回*溫度,溫度,TEMP->的getData()(返回一個const基地&)等
「我有麻煩」不是一個適當的問題描述。 –
感謝您的意見,您對我的問題的解決方案有任何建議嗎? –
請閱讀[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve) – GingerPlusPlus