Project Overview
Build a Student Grade Management System that demonstrates all C++ concepts you've learned.
- Classes with encapsulation and inheritance
- Templates for generic data handling
- STL containers (vector, map, set)
- File I/O for data persistence
- Exception handling for robust error management
- Smart pointers for safe memory management
Core Implementation
Design the class hierarchy and data structures for the grade system.
Example
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
class Student {
private:
string name;
int id;
vector<double> grades;
public:
Student(string n, int i) : name(n), id(i) {}
void addGrade(double g) {
if (g < 0 || g > 100) throw invalid_argument("Invalid grade");
grades.push_back(g);
}
double average() const {
if (grades.empty()) return 0;
return accumulate(grades.begin(), grades.end(), 0.0) / grades.size();
}
char letterGrade() const {
double avg = average();
if (avg >= 90) return 'A';
if (avg >= 80) return 'B';
if (avg >= 70) return 'C';
if (avg >= 60) return 'D';
return 'F';
}
friend ostream& operator<<(ostream& os, const Student& s) {
os << s.name << " (ID: " << s.id << ") - Avg: "
<< s.average() << " (" << s.letterGrade() << ")";
return os;
}
}; 