Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pleas do this program in c++ ASAP Write a class named Employee that has the foll

ID: 3552595 • Letter: P

Question

Pleas do this program in c++ ASAP

Write a class named Employee that has the following member functions: name - a char * type to hold the employee's full name idNumber - an mf type to hold the employee's ID number department - a char * type to hold the employee's department The class should have the following member functions: A default constructor that accepts the following values as argument and assigns them to the appropriate member variables: employee's name, id number and department. Must use dynamic memory allocation for name and department. A destructor to free memory for data members whose memories were allocated by new operator. A printer function that display all data members in three lines. Write a main program to create two objects with some data (you car. pass proper data) and then call print function for each object.

Explanation / Answer



// This is Employee.h file



#ifndef E

#define E


#include <iostream>

#include <string>




class Employee

{

public:

Employee (std::string, int, std::string, std::string);

Employee (std::string, int);

Employee ();

void setName (std::string);

void setIdNumber (int);

void setDepartment (std::string);

void setPosition (std::string);

void displayEmployee ();



private:

std::string name;

int idNumber;

std::string department;

std::string position;


};


#endif



// This is the Employee.cpp file



#include <iostream>

#include "Employee.h"


using namespace std;


Employee::Employee(std::string _name, int _idNumber, std::string _department, std::string _position)

{

name = _name;

idNumber = _idNumber;

department = _department;

position = _position;

}


Employee::Employee (std::string _name, int _idNumber)

{

name = _name;

idNumber = _idNumber;

department = "";

position = "";

}


Employee::Employee ()

{

name = "";

idNumber = 0;

department = "";

position = "";

}


void Employee::setName (std::string _name)

{

name = _name;

}


void Employee::setIdNumber (int _idNumber)

{

idNumber = _idNumber;

}


void Employee::setDepartment (std::string _department)

{

department = _department;

}


void Employee::setPosition (std::string _position)

{

position = _position;

}

void Employee::displayEmployee ()

{

cout << "Name: " << name << endl;

cout << "ID Number: " << idNumber << endl;

cout << "Department: " << department << endl;

cout << "Position: " << position << endl;

cout << endl;

}



// This is the main.cpp file



#include <iostream>

#include <string>

#include "Employee.h"


using namespace std;


int main()

{

// Create an Employee object to test constructor #1.

Employee susan("Susan Meyers", 47899, "Accounting", "Vice President");


// Create an Employee object to test constructor #2.

Employee mark("Mark Jones", 39119);

mark.setDepartment("IT");

mark.setPosition("Programmer");


// Create an Employee object to test constructor #3.

Employee joy;

joy.setName("Joy Rogers");

joy.setIdNumber(81774);

joy.setDepartment("Manufacturing");

joy.setPosition("Engineer");


// Display each employee's data.

susan.displayEmployee();

mark.displayEmployee();

joy.displayEmployee();


system("pause");

return 0;

}