create a class called consultCo that holds a private struct called employee that
ID: 3579141 • Letter: C
Question
create a class called consultCo that holds a private struct called employee that contains the name, pay rate and social security number of an employee of a consulting firm called consultCo. The consultCo class should also have a vector that holds all of the objects of all of the employees in the vector. This will be a vector of employee objects. The consultCo class must be enclosed in a custom namespace. You can choose the name of the namespace. (3 points). Here is a logical diagram of this vector of objects: object of the employee class name Ones Pay later SSN vector of objects Liang Davis Allen (objects may contain 134 2 2.9 more than one type) You will also need functions to satisfy the following requirements: Minimum Requirements: main (5) cppExplanation / Answer
#include <iostream>
#include<cstring>
#include<vector>
using namespace std;
namespace n1{
struct employee{
string name,ssn;
float payrate;
};
class consultCo{
employee e;
vector<employee> e1;
public:
void hireNewEmp(string n,string id,float rate){
e.name=n;
e.ssn=id;
e.payrate=rate;
e1.push_back(e);
}
void display(){
cout<<" Name:"<<e.name;
cout<<" ssn:"<<e.ssn;
cout<<" payrate:"<<e.payrate<<endl;
}
void raise(){
e.payrate=e.payrate+e.payrate*(10.0/100);
}
};
}
using namespace n1;
int main(void){
consultCo c1,c2,c3;
c1.hireNewEmp("aditya","DIS112",12500);
c1.display();
c2.hireNewEmp("max","SS1525",10000);
c2.display();
c3.hireNewEmp("dev","ADC152",20000);
c3.display();
c1.raise();
c1.display();
return(0);
}
*************************output**************************
Name:aditya
ssn:DIS112
payrate:12500
Name:max
ssn:SS1525
payrate:10000
Name:dev
ssn:ADC152
payrate:20000
Name:aditya
ssn:DIS112
payrate:13750
--------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.