I wrote this function to trace a certain spot in a topological tree. However for some reason. Its infinite.
int electricity(int x){
multimap<int,entita,greater<int> >::reverse_iterator it = siet.rbegin();
advance(it,x-1);
if((*it).second.z=='E') return (*it).second.i;
return electricity((*it).first);
}
I debugged the variables in runtime and I am 100% certain that X is different from (*it).first. Yet for some reason, with every next function call the x remains the same. In this case (4). Any idea why?
You will get an infinite recursion when the multimap contains an item that “refers” to itself or another item that directly or indirectly “refers” back to it.
To break the infinite recursion you have a couple of options: