Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add to the class Employee the value semantics or the big three (Copy constructor, overloaded assignment operator and destructor). Write a new driver, called ex4_3.cpp,

Add to the class Employee the value semantics or the big three (Copy constructor, overloaded assignment operator and destructor). Write a new driver, called ex4_3.cpp, that creates two objects of type Employee using pointers. The first employee is called Marcy and her SSN is 678-09-1234. The second employee is Michael and his SSN is 123-99-4567. Then the program swaps the value of the two objects using the pointers. Print the result before and after the swap occurs. Add another employee (with new name and ssn) and then define a findssn function which returns employee name given the ssn. Modify the driver to test the findssn function.

The code I have so far:

#include #include

using namespace std; //Class employee class Employee { public: string employee_name; string employee_ssn; private: };

int main() { //Gathers the number of employees from the user int employees; cout << "How many employees? " << endl; cin >> employees; Employee *arr = new Employee[employees]; //While employees > i, the user is asked to enter the name of the employee and then the SSN. for (int i = 0; i < employees; ++i) { cout << "Enter employee name " << i + 1 << ": " << endl; cin >> arr[i].employee_name; cout << "Enter employee SSN " << i + 1 << ": " << endl; cin >> arr[i].employee_ssn; } // print array cout << endl << endl; for (int i = 0; i < employees; ++i) { cout << "Employee " << i + 1 << ": " << "name: " << arr[i].employee_name << endl << "ssn: " << arr[i].employee_ssn << endl << endl;

} //Delete's before exiting delete[] arr; system("pause"); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

6. Why is the plan recommended?

Answered: 1 week ago