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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include<iostream>
using namespace std;
#include <cstring>
const int DEFAULT = 81;
class Employee
{
private:
char employeeName[DEFAULT];
int idNumber;
char department[DEFAULT];
char jobPosition[DEFAULT];
public:
Employee()
{
strcpy (employeeName, "Susan Meyers");
idNumber = 47899;
strcpy (department, "Accounting");
strcpy (jobPosition, "Vice President ");
}
Employee(char *employ, char *depart, char *job)
{
strcpy (employeeName, "Mark Jones");
idNumber = 39119;
strcpy (department, depart);
strcpy (jobPosition, job);
}
Employee(char *employ, char *depart, char *job, int id )
{
strcpy (employeeName, employ);
idNumber = id;
strcpy (department, depart);
strcpy (jobPosition, job);
}
void setDepartment(char *depart)
{ strcpy(department, depart); }
void setName(char *employ)
{ strcpy (employeeName, employ); }
void setPosition(char *job)
{ strcpy (jobPosition, job); }
void setIdNumber(int id)
{ idNumber = id; }
char *getName()
{ return employeeName; }
char *getDepartment()
{ return department; }
char *getJobPosition()
{ return jobPosition; }
int getIdNumber()
{ return idNumber;}
};
int main()
{
// Create an Employee object to test constructor #1.
Employee susan;
// Create an Employee object to test constructor #2.
Employee mark;
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.
cout << susan.getName() << endl;
cout << susan.getDepartment() << endl;
cout << susan.getJobPosition() << endl;
cout << susan.getIdNumber() << endl << endl;
cout << joy.getName() << endl;
cout << joy.getDepartment() << endl;
cout << joy.getJobPosition() << endl;
cout << joy.getIdNumber() << endl << endl;
cout << mark.getName() << endl;
cout << mark.getDepartment() << endl;
cout << mark.getJobPosition() << endl;
cout << mark.getIdNumber() << endl << endl;
system("pause");
return 0;
|