0% found this document useful (0 votes)
35 views

Void Using Namespace Class Protected Char Char Char Int Char Public

This C++ program defines classes for Person, Student, and Teacher. The Person class contains basic attributes like name, ID, gender, etc. The Student and Teacher classes inherit from Person and contain additional attributes specific to those roles. The main function displays a menu and allows the user to enroll new records by inputting attributes, display all records, or perform other operations like search, update, and delete.
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)
35 views

Void Using Namespace Class Protected Char Char Char Int Char Public

This C++ program defines classes for Person, Student, and Teacher. The Person class contains basic attributes like name, ID, gender, etc. The Student and Teacher classes inherit from Person and contain additional attributes specific to those roles. The main function displays a menu and allows the user to enroll new records by inputting attributes, display all records, or perform other operations like search, update, and delete.
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/ 4

#include<iostream>

#include<conio.h>
void Menu();
using namespace std;
class Person
{
protected:
char Name[30];
char ID[15];
char Gender;
int Age;
char Ph_No[15];
public:
Person()
{
Name[0]=NULL;
ID[0]=NULL;
Gender=NULL;
Age=0;
Ph_No[0]=NULL;
}
void pget()
{
cout<<"Enter Name : ";
cin>>Name;
cout<<"Enter ID : ";
cin>>ID;
cout<<"Enter Gender (M/F) : ";
cin>>Gender;
cout<<"Enter Age : ";
cin>>Age;
cout<<"Enter Phone # : ";
cin>>Ph_No;
}
void pdisplay()
{
cout<<"Name : "<<Name<<endl;
cout<<"ID : "<<ID<<endl;
cout<<"Gender : "<<Gender<<endl;
cout<<"Age : "<<Age<<endl;
cout<<"Phone # : "<<Ph_No<<endl;
}

};
class Student:public Person
{

char StudentName[10];
int Semester;
char Section;
float CGPA;
int Fee;
public:
Student()
{
StudentName[0]=NULL;
Semester=0;
CGPA=0.0;
Fee=0;
Section=NULL;
}
void getstudent()
{

cout<<"enter Student NAME:";


cin>>StudentName;
cout<<"Enter Semester : ";
cin>>Semester;
cout<<"Enter Section : ";
cin>>Section;
cout<<"Enter CGPA : ";
cin>>CGPA;
cout<<"Enter Fee : ";
cin>>Fee;
}
void sdisplay()
{
//Person::display();
cout<<"Student Name:"<<StudentName<<endl;
cout<<"Semester : "<<Semester<<endl;
cout<<"Section : "<<Section<<endl;
cout<<"CGPA : "<<CGPA<<endl;
cout<<"Fee : "<<Fee<<endl;
}
};
class Teacher:public Person
{
char Designation[20];
int Salary;
char TeacherName[10];
public:
Teacher()
{
Designation[0]=NULL;
Salary=0;
TeacherName[0]=NULL;
}
void get()
{
cout<<"Enter Designation : ";
cin>>Designation;
cout<<"Enter Salary : ";
cin>>Salary;
cout<<"Enter Teacher Name : ";
cin>>TeacherName;
}
void tdisplay()
{
cout<<"Designation : "<<Designation<<endl;
cout<<"Salary : "<<Salary<<endl;
cout<<"TeacherName:"<<TeacherName<<endl;
}
void getTeacher()
{
cout<<"Enter Designation : ";
cin>>Designation;
cout<<"Enter Salary : ";
cin>>Salary;
cout<<"Enter teacher Name : ";
cin>>TeacherName;
}
};
void main()
{
Person p;
Teacher t;
Student s;
char choice;
do{
Menu();
choice=_getche();
system("cls");
cout<<endl;
switch(choice)
{
case '1':
p.pget();
t.get();
s.getstudent();
break;
case '2':
p.pdisplay();
t.tdisplay();
s.sdisplay();
break;
case '3':
system("pause");

break;
case '4':

system("pause");
break;
case '5':

system("pause");
break;
case '0':

system("pause");
default:
cout<<"Wrong Input.Please Input Again"<<endl;
}
}while(choice!='0');

}
void Menu()
{

cout<<"\t||Welcome To Administration||"<<endl;
cout<<" Press 1 to Enrollment"<<endl;
cout<<" Press 2 to Display All Records"<<endl;
cout<<" Press 3 to Search Record"<<endl;
cout<<" Press 4 to Update Record"<<endl;
cout<<" Press 5 to Delete Record"<<endl;
cout<<" Press 0 Exit"<<endl;

You might also like