Python__OOP Lab 15 (1)
Python__OOP Lab 15 (1)
OBJECTIVES:
(i) To use the concept of virtual, pure virtual and friend functions in a real-life
implement of classes
Name:
SAP:
EEDEPARTMENT
Introduction:
This is a comprehensive student management system designed to simplify the process of managing
student records. The system provides a range of features, including the ability to add new students,
view existing student records, search for specific students, and delete student records as needed. Built
using the C++ programming language, this console-based application is easy to use and provides a
user-friendly interface for managing student data.
#include <iostream>
using namespace std;
public:
virtual void addStudentRecord() = 0; // Pure virtual function
virtual void viewStudentRecord() = 0; // Pure virtual function
int getRollNo()
{
return rollNo;
}
EEDEPARTMENT
string getName()
{
return name;
}
int getMarks()
{
return marks;
}
public:
StudentManagementSystem()
{
count = 0;
}
EEDEPARTMENT
else
{
cout << "Cannot add more records." << endl;
}
}
void viewAllStudentRecords() {
for (int i = 0; i < count; i++) {
students[i].viewStudentRecord(); // Calls the derived class method
cout << endl;
}
}
EEDEPARTMENT
int main() {
StudentManagementSystem sms;
int choice;
while (choice != 6) {
cout << "\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
cout << "Student Management System" << endl;
cout << "1. Add Student Record" << endl;
cout << "2. View Student Record" << endl;
cout << "3. View All Student Records" << endl;
cout << "4. Search Student Record" << endl;
cout << "5. Display Record Count" << endl;
cout << "6. Exit" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\
n";
EEDEPARTMENT
if (choice == 1)
{
sms.addStudentRecord();
}
else if (choice == 2)
{
int rollNo;
cout << "Enter student roll number: ";
cin >> rollNo;
cout << endl << endl;
sms.viewStudentRecord(rollNo);
}
else if (choice == 3)
{
sms.viewAllStudentRecords();
}
else if (choice == 4)
{
string name;
cout << "Enter student name: ";
cin >> name;
cout << endl << endl;
sms.searchStudentRecord(name);
}
else if (choice == 5)
{
displayRecordCount(sms); // Display the count using the friend function
Object Oriented Programming 2nd Semester-EE RCST Lahore
Riphah College of Science and Technology,Lahore
FACULTY OF Electrical Engineering
EEDEPARTMENT
}
else {
cout << endl << "Exited" << endl;
}
}
return 0;
}
Conclusion