I think this is the reason for your complaint:
http://www.cplusplus.com/forum/articles/7312/
A couple of comments on the input functions:
The
istream::
clear() function does
not reset the input stream. It clears all error flags. --There is a big difference.
Before I continue further, suppose I input the following student information:
John 95 100 80 88
Jane 96 99 81 81
Joseph 84 92 82 82
Aleah 97 100 83 83
|
The first time through the read() function, you read "John" as the student name, "95" as his midterm, an "100" as his final. Then you move into the read_hw() function, where you read homework grades of "80" and "88". Since no error has occurred, the function continues and attempts to read "Jane" as the next homework grade. This, of course, fails, so the function terminates, and it is required to clear() the input stream's error flags so that you can continue with the next function. (This design is, BTW, the reason why your input has to terminate
twice for the program to continue.)
Since each line is its own record, it is better to read the entire line, then use a
stringstream to break it up.
Hope this helps.
[edit] Oh yeah, I forgot to mention that lines 18 and 21 in Student_info.cpp are mutually exclusive, and hence, unnecessary. Good luck!