Write a class named Employee that has the following member variables:
• name. A string that holds the employee’s name.
• idNumber. An int variable that holds the employee’s ID number.
• department. A string that holds the name of the department where the employee works.
• position. A string that holds the employee’s job title.
The class should have the following constructors:
• A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name, employee’s ID number, department, and position.
• A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name and ID number. The department and position fields should be assigned an empty string (“ “);
• A default constructor that assigns empty strings (“ “) to the name, department, and position member variables, and 0 to the idNumber member variable.
Write appropriate mutator functions that store values in these member variables and accessor functions that return the values in these member variables. Once you have written the class, create a three Employee objects (3 separate instances), in your main function, to hold the following data.
Name ID Number Department Position
Susan Meyers 47899 Accounting Vice President
Mark Jones 39119 IT Programmer
Joy Rogers 81774 Manufacturing Engineer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include "stdafx.h"
#include <iostream>
using namespace std;
// class declaration
class emoployee
{
private:
char name; // holds employee name
double idNumber; // holds employee number
char department; // holds the name of department
char position; // holds job title
public:
void setName(char);
void setidNumber(double);
void setDepartment(char);
void setPosition(char);
char getName()const;
char getidNumber()const;
char getDepartment()const;
char getPosition()const;
};
int main()
{
char employee emp1, emp2, emp3;
emp1.setName("Susan Meyers");
emp2.setName("Mark Jones");
emp3.setName("Joy Rodgers");
char name; // employee name
double idNumber; // To hold a number
char department; // name of the department
char position; // name of job title
employee::employee(char name, double idNumber, char department, char position)
name = name;
idNumber = idNum;
department = dept;
position = post;
employee::employee(char department, char position)
getDepartment();
getPosition();
employee::employee(char department, char position, double idNumber)
getDepartment();
getPosition();
getidNumber(0);
return 0;
|