Question: 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 Q1 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 input/output remains unchanged.
The program in Q1 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 Q1 and run the program using the followig main, and the input values from Q1. 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. hm
int main (void)
{
char type; // employee type
ofstream fout ("employeetypesout.tt?;
employee ptr :
vector (:=1'
q1code
/ #include employeetypes.h
int main(void)
{
char type;
ofstream fout( employeetypesout.txt );
while (true){
cout endl Type of employee(enter l for laboUrer, m for manager, q to quit) : ;
cin >> type;
if(type == q ) break;
if(type == l ){
labourer lab;
lab.read(cin);
cout endl;
lab.write(cout);
fout endl;
lab.write(fout);
} else if(type ==m){
manager man;
man.read(cin);
cout endl;
man.write(cout);
fout endl;
man.write(fout);
}
}
fout.close();
return 0;
}
#pragma once
#ifndef EMPLOYEETYPES_H
#define EMPLOYEETYPES_H
#include
#include
#include
using namespace std;
class Date {
private:
int day;
int month;
int year;
public:
Date() : day(0), month(0), year(0){}
Date(int d, int m, int y) : day(d), month(m), year(y){}
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(0), salary(0.0){}
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;
}
 Modify the program in Q1 to use overloaded operators operator and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!