Exercise 3: Suppose that an employee for the military is represented by class ca
ID: 3546079 • Letter: E
Question
Exercise 3:
Suppose that an employee for the military is represented by class called Employee. For each employee there is :
- Name
- ID
- Salary
You have to do the following tasks:
- Overload the specified operator.
- Write the main function to test (++ postfix operator) & (<< operator) overloading function.
#include <iostream>
#include <string>
using namespace std;
class Employee {
int ID;
string Name;
float *Salary;
public:
Employee (int id, string n, float s)
{
setID(id);
setName(n);
Salary= new float;
setSalary (s);
}
void setID(int id)
{
ID=id;
}
void setName(string n)
{
Name=n;
}
void setSalary (float s)
{ *Salary =*s; this is wrong since Salary point to nothing
*Salary =s;
}
//overload the insertion << operator to print the employee information
//overload ++(postfix) operator as member function to increase the employee salary by 1000$
};
int main()
{ // test here the overloading functions.
return 0;
}
Explanation / Answer
I can help with this problem. contact me at omerkhan.nu@gmail.com
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.