Question: Debug. You may copy and paste then correct on side of wrong one and highlight your correction. Each correct change you will gain one point.
Debug. You may copy and paste then correct on side of wrong one and highlight your correction. Each correct change you will gain one point. Each time you change a correct statement to wrong, 1 point will be subtract from your total gain.
include
using namespace std
Class Employee{
public
// friend functions
friend boolean equal(const Employee& e1, const Employee e2);
// return true if two employees have the same id; false otherwise
friend istream& operator >> (istream& ins, Employee e);
// input es id and salary from istream ins
friend ostream& operator << (ostream& outs, const Employee& e); // output es id and salary
// constructors
employee();
// initialize id to be 0 and salary to be 0.0
Employee(int id);
// initialize id to be given id and salary to be 0.0
Employee(int id, double salary);
// initialize id to be given id and salary to be given salary
// member functions
int get_id();
double get_salary();
void set_id(int id);
void set_salary(double salary);
private:
int _id;
double _salary;
}
int main()
{
Employee employee1(1000, 23000.00);
Employee employee2;
cout << "Enter the information of the employee, id and salary, separated by white space: ";
cin >> employee2;
cout << "The employee1s salary is $" << employee1.get_salary();
if(equal(employee1, employee2))
cout << "Two employees are the same guy.";
else
cout << "Two employess are different guys";
return 0;
}
bool Employee::equal(constant Employee& e1, constant Employee e2)
{
return e1._id == e2._id;
}
istream& operator >> (istream& ins, Employee& e)
{
ins >> e.id;
ins >> e.salary;
return ins;
}
ostream& operator << (ostream& outs, const Employee& e)
{
outs << "ID: " << e._id << ", Salary: " << e._salary;
}
// constructors
Employee::Employee(): _id(0); _salary(0.0) {}
Employee::Employee(int id)
{
_id = id;
_salary = 0.0;
}
Employee::Employee(int id, double salary)
{
id = _id;
salary = _salary;
}
// member functions
int Employee:: get_id()
{
return _id;
}
double Employee::get_salary()
{
return _salary;
}
void set_id(int id)
{
_id = id;
}
void Employee::set_salary(double salary)
{
_salary = salary;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
