with header file and implemantation plz We want to create a C++ system that mana
ID: 666458 • Letter: W
Question
with header file and implemantation plz
We want to create a C++ system that manages the employees of a pharmaceutical company. The company has two types of employees: Researchers and Administrators. Both types of employees have the following properties: employee id (int), name (string), position (string), seniority (int). In addition, researchers have the following attributes: title (string) and area of expertise (string). Administrative employees have the following additional attributes: number of employees that are managed by the employee (int). It is up to you to decide how many classes are needed. You decide about which functions should be virtual, constant, etc. You need to provide both a class definition and implementation. Each class must have at least the following functions: • A default constructor, a regular constructor, a copy constructor, a destructor • Accessing functions • A print function You can also reuse the class Company created from assignment 2. The class Company has the following attributes: name (string) address (string), list of employees (an array of objects of the Employee class), and number of employees the company has (int). The class must implement the following functions: • A default constructor, a regular constructor, a copy constructor, a destructor • Accessing functions • A function that adds an employee to the company (an exception should be thrown if the employee already exists) • A function that removes an employee from the company (an exception should be thrown if the employee does not exist) • A function that returns the number of employees of the company • A function that returns the list (names) of the employees • A function that prints out the name and address of the company
Explanation / Answer
Hi,
Answer to the question:
#include<iostream.h>
#include<conio.h>
/*
Company class
*/
class Company
{
protected :
char name[15];
char address[50];
int emp_id;
char emp_name[20];
char emp_position[10];
int seniority;
public:
void getdetails();
void disp();
void no_of_employees();
void names_of_employees();
void company_details();
Company();//Default constructor
~Company();//Default destructor
};
}
class Researchers: public Company
{ protected :
int no_of_emp_managed;
public:
void getReasearchersDetails();
void addResearchers();
void addReasearchersDetails();
Researchers();//Default constructor
Researchers(char emp_name[10],int seniority);//Regular constructor to display the researchers name and other details
};
class Administrators: public Company
{ public:
void getAdminDetails();
Administrators();//Default constructor
Administrators(char emp_name[10],int seniority);//Regular constructor to display the researchers name and other details
};
void Company::company_details()
{ cout<<" Enter name of the company : ";
cin>>name;
cout<<" Enter address of company : ";
cin>>address; }
void Company::getdetails()
{
cout<<" Enter name of the Employee : ";
cin>>emp_name;
cout<<" Enter the employee id of the employee : ";
cin>>emp_id;
cout<<" Enter the position of the employee : ";
cin>>emp_position;
cout<<" Enter the seniority of the employee : ";
cin>>seniority; }
void Company::disp() {
cout<< name of the employee is: <<" "<< emp_name <<" ";
cout<< employee id of the employee is: <<" "<< emp_id <<" ";
cout<< Position of the employee is: <<" "<< emp_position <<" ";
cout<< Seniority of the employee is: <<" "<< seniority <<" ";}
void Company::names_of_employees() {
getdetails();
cout<< Name of researchers is : "<<name<<" ";
}
void Company::no_of_employees(){
Company::getdetails();
if(!emp_name)
{
cout<<"No employess found ";
else{
int count
count++;}
}
cout<< no of researchers is: "<<count<<" "; }
Company : : ~Company( )
{
cout<<”Company Details is Closed”;
}
void Researchers::addReasearchersDetails() {
cout<<" No of employees managed by the researcher is: ";
cin>>no_of_emp_managed; }
void Researchers::getReasearchersDetails() {
Company::getdetails();
cout<<" No of employess managed by this researcher is: ";
cin>>no_of_emp_managed; }
void Researchers::addResearchers() {
Company::getdetails();
addReasearchersDetails();
cout<<" New researchers details added: ";
cin>>no_of_emp_managed; }
/*
using constructor
*/
Researchers::Researchers(char emp_name[10],int seniority){
cout<<"employee name is:"<<emp_name<<" ";
cout<<"employee seniority:"<<seniority<<" ";
}
void Administrators::getAdminDetails() {
Company::getdetails();}
void main() {
Company comp[10];
clrscr();
int num,i;
cout<<" Enter number of employee details ";
cin>>num;
for(i=0;i<num;i++)
emp[i].getdetails();//Adds the employee details
for(i=0;i<num;i++)
emp[i].disp();//Gives employee details
for(i=0;i<num;i++)
emp[i].company_details();//Display company details
for(i=0;i<num;i++)
emp[i].names_of_employees();//Displays names of all employees
for(i=0;i<num;i++)
emp[i].no_of_employees();
Researchers Researchers();//calling constructor in main function
getch();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.