diff options
| author | Carlos Maiolino <[email protected]> | 2026-02-20 16:17:14 +0100 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2026-02-20 16:17:14 +0100 |
| commit | 4ff0e42f65d8bba3d21bed53bfe1251d8db5c13f (patch) | |
| tree | 9ac61873e2676c3f392bd26063afeb16897c3902 /CPP/cpp_book/chap6/approval.cpp | |
| parent | fd313dd5ad9ac067a31f2b1760b85bd305567131 (diff) | |
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; +} |
