1# Student Management System - Quick Start
2
3## Build and Run
4
5```bash
6# Build the project
7make
8
9# Run the program
10./student_manager
11
12# Or combine both
13make run
14```
15
16## Quick Test with Sample Data
17
18```bash
19# The program uses an interactive menu
20./student_manager
21
22# Then select option 9 to load sample data:
23Choice: 9
24Enter filename: sample_students.csv
25```
26
27## Sample Workflow
28
29```
301. Load sample data (option 9 → sample_students.csv)
312. List all students (option 5)
323. Sort by GPA (option 6 → choice 3)
334. View statistics (option 7)
345. Find a student (option 3 → ID: 1001)
356. Add new student (option 1)
367. Save database (option 8 → output.csv)
37```
38
39## Key Features Demonstrated
40
41| Feature | Menu Option | C++ Concepts |
42|---------|-------------|--------------|
43| Add Student | 1 | `std::make_shared`, exception handling |
44| Remove Student | 2 | `std::find_if`, iterators, exceptions |
45| Find by ID | 3 | Lambda expressions, algorithms |
46| Find by Name | 4 | `std::copy_if`, substring matching |
47| List All | 5 | Range-based for, operator overloading |
48| Sort | 6 | `std::sort`, custom comparators |
49| Statistics | 7 | `std::accumulate`, `std::map` |
50| Save to CSV | 8 | File I/O, serialization |
51| Load from CSV | 9 | File parsing, deserialization |
52
53## Modern C++17 Highlights
54
55```cpp
56// Smart pointers (automatic memory management)
57std::shared_ptr<Student> student = std::make_shared<Student>(...);
58
59// Lambda expressions
60std::find_if(students.begin(), students.end(),
61 [id](const auto& s) { return s->getId() == id; });
62
63// STL algorithms
64std::sort(students.begin(), students.end(),
65 [](const auto& a, const auto& b) { return a->getGpa() > b->getGpa(); });
66
67// Custom exceptions
68throw StudentNotFoundException(id);
69
70// Operator overloading
71std::cout << *student << std::endl;
72
73// Range-based for loops
74for (const auto& student : students) { /* ... */ }
75```
76
77## File Structure
78
79```
80student.h/cpp → Student class (data model)
81database.h/cpp → StudentDatabase (business logic)
82main.cpp → CLI interface (presentation layer)
83Makefile → Build configuration
84sample_students.csv → Sample data (8 students)
85```
86
87## Compilation Flags
88
89- `-std=c++17` - Use C++17 standard
90- `-Wall -Wextra -Wpedantic` - All warnings enabled
91- `-O2` - Optimization level 2
92
93## CSV Format
94
95```csv
96id,name,major,gpa
971001,Alice Johnson,Computer Science,3.85
981002,Bob Smith,Mathematics,3.92
99```
100
101## Learning Path
102
1031. Start with `student.h/cpp` - Understand basic OOP
1042. Study `database.h/cpp` - Learn STL containers and algorithms
1053. Explore `main.cpp` - See how everything connects
1064. Experiment with the Makefile - Understand build dependencies
1075. Try modifying the code - Add new features (sorting by major, search filters, etc.)
108
109## Common Tasks
110
111### Add a new sorting option
112Edit `database.cpp` and add a new method like:
113```cpp
114void StudentDatabase::sortByMajor() {
115 std::sort(students.begin(), students.end(),
116 [](const auto& a, const auto& b) {
117 return a->getMajor() < b->getMajor();
118 });
119}
120```
121
122### Add a new search filter
123```cpp
124std::vector<std::shared_ptr<Student>> findByGpaRange(double min, double max) const {
125 std::vector<std::shared_ptr<Student>> results;
126 std::copy_if(students.begin(), students.end(), std::back_inserter(results),
127 [min, max](const auto& s) {
128 return s->getGpa() >= min && s->getGpa() <= max;
129 });
130 return results;
131}
132```
133
134## Troubleshooting
135
136**Build fails:** Ensure you have g++ 7.0+ with C++17 support
137```bash
138g++ --version
139```
140
141**Warnings about unused parameters:** All warnings have been addressed in this code
142
143**File not found:** Make sure you're in the correct directory
144```bash
145pwd # Should show .../examples/CPP/student_management
146```
147
148## Next Steps
149
150- Add unit tests using Google Test or Catch2
151- Implement JSON serialization instead of CSV
152- Add a GUI using Qt or GTK
153- Create a multi-threaded version with thread-safe operations
154- Implement database persistence using SQLite