Use Of Classes And Arraysinclude Iostreamusing Namespace Std
Use of Classes and arrays #include using namespace std; // Employee class definition class Employee { private: string empName; string empAddress; string empEmail; int vacationMonths; int empVacationDays; // hold vacation days taken for every month public: void setEmpName(string); string getEmpName(); void setEmpAddress(string); string getEmpAddress(); void setEmpEmail(string); string getEmpEmail(); void setEmpVacationDays(int, int); // sets vacation days for a specific month int getEmpVacationDays(int); //gets vacation days taken in a specific month int getTotalEmpVacationDays(); //gets the total vacation days // Constructor Employee(); Employee(int); // this constructor sets up the size of the emplyee vacation array // Destructor ~Employee(); }; //definition of set/get member functions of Employee class void Employee::setEmpName(string name) { empName=name; } void Employee::setEmpAddress(string address) { empAddress=address; } void Employee::setEmpVacationDays(int month, int vDays) { empVacationDays[month-1]=vDays; } void Employee::setEmpEmail(string email) { empEmail=email; } string Employee::getEmpName() { return empName; } string Employee::getEmpAddress() { return empAddress; } string Employee::getEmpEmail() { return empEmail; } int Employee::getEmpVacationDays(int month) { return empVacationDays[month-1]; } int Employee::getTotalEmpVacationDays() { int sum = 0; for (int i=0; iemp) { cout getEmpName() void viewAddress(Employee emp) { cout getEmpName() getEmpAddress() void viewEmail(Employee emp) { cout getEmpName() getEmpEmail() int totalVacationDays(Employee emp) { return emp->getTotalEmpVacationDays(); } // returns vacation days taken for a specific month for int vacationDaysMonth(Employee emp, int month) { return emp->getEmpVacationDays(month); } int main(void) { // variable declaration section char selection = ' '; string months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; Employee employee1; //Initialize employee1 members employee1.setEmpName("John Smith"); employee1.setEmpAddress("1235 Main Street"); employee1.setEmpEmail(" [email protected] "); employee1.setEmpVacationDays(1, 2); // 2 vacation days taken in the month of January employee1.setEmpVacationDays(7, 8); // 8 vacation days taken in the month of July //display employee name cout >selection; switch(selection) { case '1': cout "; int month; cin >> month; cout