【发布时间】:2011-09-16 22:19:43
【问题描述】:
在 c++ 中返回布尔值的问题..
bool find( const TrieNode &node, const string word )
{
if (word.length() == 0)
{
if (node.isWord)
{
cout << "TRUE" << endl;
return true;
}
else
{
cout << "FALSE" << endl;
return false;
}
}
char firstletter = word.at(0);
int index = firstletter - 'a';
if (node.letters[index] == NULL)
{
return false;
}
else
{
find (*node.letters[index],word.substr(1,(word.length() - 1)));
}
}
我主要有
cout << find(*mynode,"word") << endl;
将屈服于:
错误
95
显然,FALSE 的 cout 意味着该函数返回 false。但是,当我打印出函数的结果时,我得到 95,它的计算结果为 true。有什么理由这样做吗?
谢谢
【问题讨论】: