Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(c++) Add a copy constructor, overloaded assignment operator and destructor to the class Employee. Write a new driver that creates two objects of type Employee

(c++) Add a copy constructor, overloaded assignment operator and destructor to the class Employee. Write a new driver 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.

My code for the class:

#include using namespace std; using namespace std; class Employee { public: string employee_name; string employee_SSN; }; int main() { int size; cout << "Enter the Number of Employees: "; cin >> size; Employee *empArray = new Employee[size]; for(int i = 0; i < size; ++i) { cout << "Enter Name of Employee " << i+1 << ": "; cin >> empArray[i].employee_name; cout << "Enter the Employees SSN " << i+1 << ": "; cin >> empArray[i].employee_SSN; } for(int i = 0; i < size; ++i) { cout << endl << "Employee" << i+1 << ": "; cout << "Name: " << empArray[i].employee_name << endl; cout << "Social Security Number: " << empArray[i].employee_SSN << endl; } delete[] empArray; return 0; }

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

3. Choose an appropriate topic and develop it

Answered: 1 week ago

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago