Question: C++ LANGUAGE (Referring to the code below) Write and test a friend function that checks to see if the phone number of a an Employee
C++ LANGUAGE (Referring to the code below)
-
Write and test a friend function that checks to see if the phone number of a an Employee object is equal to the phone number of a Programmer object. Test equal and not equal scenarios. (You will need to call your ChangePhoneNumber method)
-
Overload the equality operator to see if the phone number of two Employees are the same. Test equal and not equal scenarios. (You will need to call your ChangePhoneNumber method)
-
Write an addition member function that adds an integer to an Employees age (make sure the integer is a passed parameter). The output should state how many years were added to the age.
-
Overload the addition operator to add a constant to an Employees age. For example: StarEmployee = StarEmployee + 2. The output should state how many years were added to the age.
-
Overload << and >> operators to read in an Employee object (e.g. cin >> myEmployee and cout << myEmployee)
-
Overload the pre & post increment operators to increment an Employees age. Test pre/post increment operations. Output the values of Employee objects before and after pre/post increment operations as well as after assignment takes place. Demonstrate how pre/post increment operators are different. Which overloaded operator incurs the most overhead?
The code to refer to:
// Employee class
class Employee {
protected:
string name; string phone; int age;
public:
Employee(); Employee(string name, string phone, int age); void setName(string name); void setPhoneNum(string phone); void setAge(int age); };
// default constructor
Employee::Employee() {
name = ""; phone = ""; age = 0; }
// overloaded constructor
Employee::Employee(string name, string phone, int age) {
this->name = name; this->phone = phone; this->age = age; }
// Employee class setter functions
void Employee::setName(string name) {
this->name = name; }
// ----------
void Employee::setPhoneNum(string phone) {
this->phone = phone; }
// ----------
void Employee::setAge(int age) {
this->age = age; }
// Employee class getter functions
string Employee::getName() {
return name; }
// ----------
string Employee::getPhoneNum() {
return phone; }
// ----------
int Employee::getAge() {
return age; }
Programmer class is a subclass of Employee, inherits and calls the same methods of the base (Employee) class so I didn't write the whole thing.
I would greatly appreciate your help!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
