diff options
Diffstat (limited to 'CPP/cpp_book/chap6/approval.cpp')
| -rw-r--r-- | CPP/cpp_book/chap6/approval.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/CPP/cpp_book/chap6/approval.cpp b/CPP/cpp_book/chap6/approval.cpp new file mode 100644 index 0000000..c31c7b5 --- /dev/null +++ b/CPP/cpp_book/chap6/approval.cpp @@ -0,0 +1,28 @@ +#include <vector> +#include <iostream> +#include "student_info.h" +#include "grade.h" +#include "approval.h" + +bool fgrade(const StudentInfo& s) { + return grade(s) < 60; +} + +std::list<StudentInfo> +extract_fails( + std::list<StudentInfo>& students) +{ + std::list<StudentInfo> fail; + std::list<StudentInfo>::iterator iter = students.begin(); + + while (iter != students.end()) { + if (fgrade(*iter)) { + fail.push_back(*iter); + iter = students.erase(iter); + } else { + iter++; + } + } + + return fail; +} |
