Hmm.. in my code I iterate through a list(an actual list data structure) and I run a member function of each instance of my Node class that the iterator is pointing to. Problem is, when I run the member function(which is supposed to return a stored value in the Node class) it ALWAYS returns 0. When I was debugging, I found this, and I printed the return value of the member function of the node that the iterator was pointing to(supposed to be the same value that was returned when running the same member function on the iterator) and it gave me the correct value. So this throws off my whole algorithm. The problem function is below:
Coord is a struct containing two int's(x and y). The openlist is my list, and that's about it. I'm wondering why the "iter->get_fval()" function is ALWAYS returning 0 when it should be returning the correct value? Am I accessing it properly?? Any help or insight is appreciated, thanks.Code:Coord find_lowest_fval() { int lowest=999; int temp; Coord winner; for(iter=openlist.begin();iter!=openlist.end();iter++) { temp=iter->get_fval(); if(temp<lowest) { lowest=temp; winner=iter->get_pos(); } } return winner; }



LinkBack URL
About LinkBacks



CornedBee