这次失败的C ++字符串比较,我缺少什么?

问题描述 投票:0回答:1

我正在尝试将一个字符串与一个二进制搜索树进行比较,下面的代码在第一个搜索树上起作用,但是随后在每个其他搜索树上都失败了-即使我已经检查确保它是递归地检查树。谢谢!

bool BST::compareIt(Node* current, string name)
{
    if (name == current->title)
       return true;
    if (current->left != NULL)
        compareIt(current->left, name);
    if (current->right != NULL)
        compareIt(current->right, name);
    return false;
 }

I

c++ string binary-search-tree
1个回答
0
投票

例如,您需要返回递归调用的结果

© www.soinside.com 2019 - 2024. All rights reserved.