I see a couple of issues with your reader code -- in ReadFromFile() function:
- you are breaking out of the loop before storing the last record in the list.
- you seem not to be skipping newlines at the end of the lines.
I'm surprised it's working at all without the newline skipping. Maybe a platform difference.
By my second point I mean:
Just move the break down a bit.Code:// final iteration through loop getline(InFile, Designation); //read last record getline(InFile, Agent); InFile >> Temperature; InFile >> Count; InFile >> Index; InFile.ignore(100, '\n'); // now at EOF if(InFile.eof()) break; // remaining statements are unreachable // so last record is not stored in List Temp.SetDesignation( Designation );
The other problem is with the iterator ILister. Here:
You are relying on ILister always pointing to a valid list entry when you deference it to call Convert(). This is not true here -- within GetMinF and GetMaxF you use ILister in the for loop, so when you get to here ILister is pointing past the end of the list!Code:cout << "\nLowest Temperature:\t " << GetMinF() //Second problem << "\t\t\t" << (*ILister).Convert( GetMinF() );
Basically every time you use ILister you need to initialise it first -- because you have lots of for loops that can modify the value, you can't rely on it persisting or having a sensible value. For calls like the above call to Convert() you don't seem to need a particular element -- so you could just use List.begin() I think.
Shout if any of that is unclear.