Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the program in Q 1 to use overloaded operators operator and operator rather than read ( ) and write ( ) functions. Implement these
Modify the program in Q to use overloaded operators operator and operator rather than read and write functions. Implement these operators for all the classes and modify the main program accordingly. The program inputoutput remains unchanged.
The program in Q is modified to store the workforce records of various employee types in a vector using the following main program.
a Use the declaration and implementation of classes from Q and run the program using the followig main, and the input values from Q Does the program work properly?
b Make the necessary changes to the classes not main to make the program generate the desired output.
Main Program Using Classes EmployeeTypes
File: testemployeetypes. epp
Application program using elasses employeetypes
Programimer: your name
Date:
#include "employeetypes.
int main void
char type; employee type
ofstream fout employeetypesout;
employee :
vector :
code
#include employeetypes.h
int mainvoid
char type;
ofstream fout employeetypesout.txt ;
while true
cout endl Type of employeeenter l for laboUrer, m for manager, q to quit : ;
cin type;
iftype q break;
iftype l
labourer lab;
lab.readcin;
cout endl;
lab.writecout;
fout endl;
lab.writefout;
else iftype m
manager man;
man.readcin;
cout endl;
man.writecout;
fout endl;
man.writefout;
fout.close;
return ;
#pragma once
#ifndef EMPLOYEETYPESH
#define EMPLOYEETYPESH
#include
#include
#include
using namespace std;
class Date
private:
int day;
int month;
int year;
public:
Date : day month year
Dateint d int m int y : dayd monthm yeary
void read
cout "Enter start date dd mm yyyy: ;
cin day month year;
void write const
cout "Start date: day month year endl;
;
class Employee
protected:
string name;
int id;
float salary;
Date start;
public:
Employee : name id salary
void read
cout "Enter employee name: ;
cin name;
cout "Enter employee ID: ;
cin id;
cout "Enter employee salary: ;
cin salary;
start.read;
void write const
cout "Name: name endl;
cout ID: id endl;
cout "Salary: salary endl;
start.write;
;
class Labourer : public Employee
private:
string dept;
public:
Labourer : dept
void read
Employee::read;
cout "Enter department: ;
cin dept;
void write const
Employee::write;
cout "Department: dept endl;
;
class Manager : public Employee
private:
string title;
public:
Manager : title
void read
Employee::read;
cout "Enter title: ;
cin title;
void write const
Employee::write;
cout "Title: title endl;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started