I am writing a file that should be able to take in numbers from a file, save them in an object, and then write sums out to a file. I am attempting to over load the fistream, but I seem to have run into a loop. Even after my while loop that uses the fistream is finished the program recalls the last input command in the loop and so the loop will not break. Also I need the loop to stop when it reaches the end of the input file. For now I have just put in values, but how can I set the loop to break if it reaches the end of the file?
I'm not sure I understand exactly what you are asking, but I think you will want to add a condition on line 7 of the operator>>() that will also break if the "in" file is no longer valid (eof, error, etc).