The debugger step over command jumps up and down randomly in the if-else block in the code below. It skips a line, goes back to the top, back down, up again?? I fixed the problem by changing the two return statements in the conditional (if-else) block to a single return statement after it. I would like to know why the erratic behaviour was happening though, for future reference, any help much appreciated.
Code:
pair<Node, bool> NodeStore::GetNode(const int &comparisonNodeID) const{
pair<Node, bool> rtnNodePair;
Node comparisonNode;
comparisonNode.SetNodeID(comparisonNodeID);
vector<Node>::const_iterator begin = iteTable.begin();
vector<Node>::const_iterator end = iteTable.end();
vector<Node>::const_iterator foundPos;
foundPos = find(begin, end, comparisonNode);
if (foundPos == end){ // debug mode moves erratically through this
rtnNodePair.second = false;
return rtnNodePair;
}
else{
rtnNodePair.first = *foundPos;
rtnNodePair.second = true;
return rtnNodePair;
}
}
cheers
sean