私はこのコードを書いているが、ある関数がそれ自身を再帰的に呼び出す。しかし、関数が返すときにwhileループの終わり括弧に戻りませんが、int oがどこに定義されているかを返すように見えるので、無限ループに詰まっています。それだけでしばらく再起動しますので、あなたは、しばらくの内部で任意の値を変更していない無限再帰C++
ErrorCode QuadTree::PartialSearchHelper(Key *key, const uint64_t QInternal, Iterator ** records,int l[], int pow) {
try {
uint64_t temp=(&indexVec[QInternal])->Firstchild;
uint64_t ch = (&indexVec[QInternal])->Firstchild;
for (int i = 0; i < pow; i++) {
while (!(&indexVec[temp + l[i]])->isLeaf) {
int o= l[i]; //it returns here after finishing recursion call!!!!!!!!!
PartialSearchHelper(key, temp + l[i], records, l, pow);
}
((&indexVec[temp + l[i]]))->findPartial(key, records);
}
} catch (std::bad_alloc &e) {
throw (kErrorOutOfMemory);
} catch (ErrorCode &e) {
throw (e);
} catch (...) {
throw (kErrorGenericFailure);
}
return kOk;
}
ある時点で、スタックオーバーフローが発生することがあります。 – 01100110
"しかし、int oがどこに定義されているかに戻ります。"ああ、そうではありません。 –
'indexVec [temp + l [i]]'を実行できるのはなぜですか?(&indexVec [temp + l [i]]) –