0% found this document useful (0 votes)
64 views3 pages

C++ Student Management System Code

The document defines two C++ classes: CPerson and Student. CPerson stores a person's name and identification number as private data and provides getter and setter methods to access and modify this data. The Student class inherits from CPerson and adds private data for a student ID number and grades array. Student overrides some methods from CPerson to also get/set this additional student-specific data. The main function provides a menu-driven interface to get data for a new student, display all stored student data, or exit the program.

Uploaded by

Ayhan Hasanov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views3 pages

C++ Student Management System Code

The document defines two C++ classes: CPerson and Student. CPerson stores a person's name and identification number as private data and provides getter and setter methods to access and modify this data. The Student class inherits from CPerson and adds private data for a student ID number and grades array. Student overrides some methods from CPerson to also get/set this additional student-specific data. The main function provides a menu-driven interface to get data for a new student, display all stored student data, or exit the program.

Uploaded by

Ayhan Hasanov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

#include<stdlib.h>
#include<string>

using namespace std;

class CPerson {
private:
string name;
string EGN;

public:
CPerson() : name(""), EGN("") {}

CPerson(string c_name, string c_EGN) :


name(c_name),
EGN(c_EGN) {}

void getData()
{
string c_name = "";
string c_EGN = "";
cout << "Name: "; getline(cin, c_name);
this->Setname(c_name);
cout << "EGN: "; getline(cin, c_EGN);
this->SetEGN(c_EGN);
}

void displayData()
{
cout << "Name: " << this->GetName() << endl;
cout << "EGN: " << this->GetEGN() << endl;
}

string GetName()
{
return this->name;
}

string GetEGN()
{
return this->EGN;
}
void Setname(string c_name)
{
this->name = c_name;
}
void SetEGN(string c_EGN)
{
this->EGN = c_EGN;
}

};

class Student : public CPerson {


private:
string facNumber;
float grades[5] = { 0,0,0,0,0 };
public:
Student() :CPerson(), facNumber(""), grades("") {}
Student(string c_name, string c_EGN, string c_facNumber, float c_grades) :
CPerson(c_name, c_EGN), facNumber(c_facNumber), grades(c_grades) {}

void getData();
void displayData();

void SetFacNumber(string c_facNumber)


{
this->facNumber = c_facNumber;
}
string GetFacNUmber()
{
return this->facNumber;
}
void SetGrades(float c_grades)
{
this->grades = c_grades;
}
float GetGrades()
{
return this->grades[i];
}

};
void Student::getData() {
cout << "facNumber: "; getline(cin, facNumber);
cout << "grades: "; cin >> grades[i];
}

void Student::displayData() {
cout << "facNumber: " << this->GetFacNUmber() << endl;
cout << "grades: " << this->GetGrades() << endl;
}
int main()
{
int cout = 0;
char PR;
do
{
cout << "\n Menu\n";
cout << "1- Student information: \n";
cout << "2- Display student data:\n";
cout << "\n Chose Operation or Cancel by 0\n";
cin >> operation;
switch (operation)
{
case'0':break;

case'1':Profile(cout++).getData() : break;

case'2':cout"All Student information";


for (int i = 0; i < cout; i++)
Students[i].displayData();
break;
}
} while (PR != '0');
return 0;
}

You might also like