Answer to Question #213942 in C++ for Maryam

Question #213942

Write a program of c++ with a following statement: A person can be an employee or a student. An employee may have rights of admin officer or of

academic officer. These class hierarchies represent multi-level inheritance. However, a Dean or

Head of Department(HOD) may have rights to modify the status already defined by an administrator

academic officer. Implement all these classes with appropriate data members and proper suitable

functions and within the main function, create instances of all classes and test the described working

of all these classes.


1
Expert's answer
2021-07-07T06:16:06-0400
using namespace std;


/*
	Write a program of c++ with a following statement: 
	A person can be an employee or a student. 
	An employee may have rights of admin officer or of 	academic officer. 
	These class hierarchies represent multi-level inheritance. However, a Dean or
	Head of Department(HOD) may have rights to modify the status already defined by an administrator
	academic officer. Implement all these classes with appropriate data members and proper suitable
	functions and within the main function, create instances of all classes and test the described working
	of all these classes
*/
#define ADMIN		0
#define ACADEMIC	1
class Person
{
	public:
		string Name;
		int ID;
		set_name(string s, int id)
		{
			Name = s;
			ID = id;
		}
};


class Employee:public Person
{
	public:
	int Rights;	
	set_rights(int RightsType)
	{
		Rights = RightsType;
	}
};


class HoD:public Employee
{
	public:
		Edit_Rights(int RightTypes)	
		{
			Rights = RightTypes;	
		}
};


class Student:public Person
{
	public:
	int ClassName;
	set_class(int c)
	{
		ClassName = c;
	}	
};




main(void)
{
	int r;
	class HoD E1, E2;
	class Student S1, S2;
	E1.set_name("ABC",111);
	E2.set_name("LMN",222);


	S1.set_name("XYZ",100);
	S2.set_name("ABC",200);
	S1.set_class(10);
	S2.set_class(11);


	E1.set_rights(ADMIN);
	E2.set_rights(ACADEMIC);
	
	cout<<"\n\nEmployee Name: "<<E1.Name;
	cout<<"\nEmployee ID  : "<<E1.ID;
	if(E1.Rights==ADMIN)	cout<<"\nRights       : ADMIN"; else  cout<<"\nRights       : ACADEMIC";


	cout<<"\n\nEmployee Name: "<<E2.Name;
	cout<<"\nEmployee ID  : "<<E2.ID;
	if(E2.Rights==ADMIN)	cout<<"\nRights       : ADMIN"; else  cout<<"\nRights       : ACADEMIC";
	
	cout<<"\n\nStatus after After Editing of Rights";
	E1.Edit_Rights(1-E1.Rights);
	E2.Edit_Rights(1-E1.Rights);
	cout<<"\n\nEmployee Name: "<<E1.Name;
	cout<<"\nEmployee ID  : "<<E1.ID;
	if(E1.Rights==ADMIN)	cout<<"\nRights       : ADMIN"; else  cout<<"\nRights       : ACADEMIC";


	cout<<"\n\nEmployee Name: "<<E2.Name;
	cout<<"\nEmployee ID  : "<<E2.ID;
	if(E2.Rights==ADMIN)	cout<<"\nRights       : ADMIN"; else  cout<<"\nRights       : ACADEMIC";
	
	cout<<"\n\nStudenmt Information:";
	cout<<"\nStudent's Name: "<<S1.Name;
	cout<<"\nRoll No       : "<<S1.ID;
	cout<<"\nClass         : "<<S1.ClassName;
	cout<<"\n\nStudent's Name: "<<S2.Name;
	cout<<"\nRoll No       : "<<S2.ID;
	cout<<"\nClass         : "<<S2.ClassName;
	return(0);
	
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS