OBJECT-ORIENTED PROGRAMMING PROJECT
Student Enrollment System
A C++ Console Application demonstrating Classes, Inheritance, Polymorphism,
File Handling, Exception Handling, and more.
Single-File Edition
|
Build: g++ -std=c++17
|
12 Core OOP Features
Project Overview
A menu-driven console system to manage student enrollment records — built entirely with core OOP principles in a single C++ file.
1
2
3
Person (abstract)
Student
GraduateStudent
Base class holding id, name, age
Roll number, department, CGPA
Thesis title & advisor name
4
5
6
Course
EnrollmentSystem
3 Exception Classes
Course catalog entries
Manages records, files & memory
NotFound, Duplicate, InvalidInput
Student Enrollment System — OOP Project
2
UML Class Diagram
All classes, attributes, methods, and inheritance relationships
Student Enrollment System — OOP Project
3
Class and Object
➤ WHAT IS IT?
1
➤ CODE PROOF
A class is a blueprint for data + behavior; an object is a real instance created
from that blueprint.
EnrollmentSystem system(5);
➤ HOW USED IN THIS PROJECT
newStudent = new Student(id, name, age,
roll, dept, cgpa);
// object
➔ 5 main classes: Person, Student, GraduateStudent, Course, EnrollmentSystem
➔ Objects created in main() and inside addStudent() using "new"
➤ WHY THIS PROVES IT
✓ "system" is an object of class EnrollmentSystem
✓ "new Student(...)" creates a Student object at runtime
Student Enrollment System — OOP Project
4
Encapsulation
➤ WHAT IS IT?
Binding data and functions together, and hiding data from direct outside
access.
➤ HOW USED IN THIS PROJECT
➔ Person keeps id, name, age as private
➔ Access only via public getId(), setName(), etc.
2
➤ CODE PROOF
class Person {
private:
int id; string name; int age;
public:
int getId() const { return id; }
void setName(const string& n){name=n;}
};
➤ WHY THIS PROVES IT
✓ Private: id, name, age — no direct outside access
✓ Public: getId(), setName() — safe, controlled access
Student Enrollment System — OOP Project
5
Constructors
➤ WHAT IS IT?
3
➤ CODE PROOF
Special functions that initialize an object automatically when it is created.
Student() : Person(), rollNumber("N/A"),
department("Undeclared"), cgpa(0.0) {}
➤ HOW USED IN THIS PROJECT
Student(int id, const string& name, int age,
const string& roll, const string& dept, double c)
: Person(id,name,age), rollNumber(roll)... {}
➔ Every class has a default + a parameterized constructor
➔ GraduateStudent's constructor chains into Student's
➤ WHY THIS PROVES IT
✓ Student() = default constructor (no arguments)
✓ Student(id, name, ...) = parameterized constructor
Student Enrollment System — OOP Project
6
Destructor
➤ WHAT IS IT?
A special function that runs automatically when an object is destroyed, to
free resources.
➤ HOW USED IN THIS PROJECT
➔ Person has a virtual destructor for safe cleanup chain
➔ EnrollmentSystem's destructor frees all Student memory
4
➤ CODE PROOF
virtual ~Person() { }
~EnrollmentSystem() {
for (int i = 0; i < count; ++i)
delete students[i];
delete[] students;
}
➤ WHY THIS PROVES IT
✓ "virtual" ensures correct derived destructor runs first
✓ ~EnrollmentSystem() releases every dynamic allocation
Student Enrollment System — OOP Project
7
Inheritance
➤ WHAT IS IT?
5
➤ CODE PROOF
A class reuses attributes/behavior of another class, forming an "is-a"
relationship.
class Student : public Person { ... };
➤ HOW USED IN THIS PROJECT
class GraduateStudent : public Student {
...
};
➔ Single Inheritance: Student inherits from Person
➔ Multilevel: GraduateStudent -> Student -> Person
➤ WHY THIS PROVES IT
✓ Student reuses Person's id, name, age
✓ GraduateStudent reuses everything from Student too
Student Enrollment System — OOP Project
8
Polymorphism
➤ WHAT IS IT?
The same function call behaves differently depending on the actual object
type (runtime behavior).
➤ HOW USED IN THIS PROJECT
➔ displayInfo() overridden in Student and GraduateStudent
➔ Base pointer calls the correct version automatically
6
➤ CODE PROOF
void displayInfo() const override {
Student::displayInfo();
cout << "Thesis: " << thesisTitle;
}
sorted[i]->displayInfo(); // runtime decision
➤ WHY THIS PROVES IT
✓ Function overridden with same name in each class level
✓ Correct version picked at runtime via virtual function
Student Enrollment System — OOP Project
9
Abstraction
➤ WHAT IS IT?
Hiding internal details, exposing only the essential interface to the outside.
➤ HOW USED IN THIS PROJECT
➔ Person declares pure virtual functions ("= 0")
➔ This makes Person abstract — cannot create Person objects
7
➤ CODE PROOF
class Person {
public:
virtual void displayInfo() const = 0;
virtual string getFileString() const = 0;
};
// Person p; -> ERROR: abstract class
➤ WHY THIS PROVES IT
✓ "= 0" marks pure virtual functions — no body in Person
✓ Derived classes must implement the actual behavior
Student Enrollment System — OOP Project
10
Friend Function
➤ WHAT IS IT?
A non-member function that is still allowed direct access to a class's
private/protected data.
➤ HOW USED IN THIS PROJECT
➔ compareStudents() and operator<< are friends of Student
➔ displayCourseInfo() is a friend of Course
8
➤ CODE PROOF
friend bool compareStudents(const Student& a,
const Student& b);
bool compareStudents(const Student& a,
const Student& b) {
return a.cgpa > b.cgpa; // direct access
}
➤ WHY THIS PROVES IT
✓ Declared with "friend" inside the class
✓ "a.cgpa" proves direct access to a protected member
Student Enrollment System — OOP Project
11
Dynamic Memory Allocation
➤ WHAT IS IT?
Allocating memory at runtime with "new", and releasing it with "delete"
when done.
➤ HOW USED IN THIS PROJECT
➔ Scenario 1: each Student created/deleted individually
➔ Scenario 2: students array grows via resizeArray()
9
➤ CODE PROOF
newStudent = new Student(id, name, age,
roll, dept, cgpa);
delete students[idx];
Student** newArr = new Student*[newCapacity];
delete[] students;
➤ WHY THIS PROVES IT
✓ "new" / "delete" -> single object allocation
✓ "new[]" / "delete[]" -> whole array growth
Student Enrollment System — OOP Project
12
File Handling
➤ WHAT IS IT?
Reading from and writing to external files so data survives after the program
closes.
➤ HOW USED IN THIS PROJECT
➔ saveToFile() writes all records to students.txt
10
➤ CODE PROOF
ofstream outFile(filename);
outFile << students[i]->getFileString() << "\n";
ifstream inFile(filename);
while (getline(inFile, line)) { ... }
➔ loadFromFile() reads and rebuilds the records
➤ WHY THIS PROVES IT
✓ ofstream -> writing data out to a file
✓ ifstream + getline() -> reading data back in
Student Enrollment System — OOP Project
13
Exception Handling
➤ WHAT IS IT?
Detecting and responding to runtime errors safely, instead of crashing the
program.
➤ HOW USED IN THIS PROJECT
➔ 3 custom exceptions: NotFound, Duplicate, InvalidInput
➔ try/throw/catch used in addStudent(), searchStudent()...
11
➤ CODE PROOF
try {
if (idx == -1)
throw StudentNotFoundException(id);
} catch (const StudentNotFoundException& e) {
cout << "Error: " << e.what();
}
➤ WHY THIS PROVES IT
✓ "throw" raises the custom exception
✓ "catch" safely handles it with a clear message
Student Enrollment System — OOP Project
14
Arrays of Objects
➤ WHAT IS IT?
12
➤ CODE PROOF
A collection where each element is itself an object of a class.
Student** students;
Course courseCatalog[5];
➤ HOW USED IN THIS PROJECT
courseCatalog[0] = Course("CS101",
"Introduction to Programming", 3);
➔ Student** students — dynamic array of pointers
// dynamic array
// static array
➔ Course courseCatalog[5] — fixed-size static array
➤ WHY THIS PROVES IT
✓ students[] grows at runtime — holds Student pointers
✓ courseCatalog[5] holds 5 Course objects directly
Student Enrollment System — OOP Project
15
Conclusion
This project successfully implements all 12 core Object-Oriented Programming concepts within a single, well-structured C++ console
application.
✓ Class & Object
✓ Encapsulation
✓ Constructors
✓ Destructor
✓ Inheritance
✓ Polymorphism
✓ Abstraction
✓ Friend Function
✓ Dynamic Memory
✓ File Handling
✓ Exception Handling
✓ Arrays of Objects
Thank You
Student Enrollment System | C++ OOP Project