Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this program in C++ Question 2 (30 points) Consider a class Employee with data members age an integer), id (an integer)

I need help with this program in C++

image text in transcribed

image text in transcribed

Question 2 (30 points) Consider a class Employee with data members age an integer), id (an integer) and salary la float), and their corresponding member functions as follows: class Employee private: intage: int id: float salary. public: Employee ): default constructorage 0 id=0, and salary- Employee Employee &x). W copy constructor Employee& operator - (Employee &x). // equal sign operator void setAge(int x). W let age = x void setld(int x); let id = x void set Salary(float x); // salary int getAge(); return age int geld ); return id float getSalary(): retur salary void print(); // print out the values of attributes on computer screen You need to provide the definition of the default constructor and the first three member functions (setAge, seild and set Salary) inside the scope defined by the brackets of class Employee and other three member functions (getAge, getid, and get Salary) outside the scope defined by the brackets of class Employee, as shown in the following skeleton: class Employee Employee ) void setAge(int x) 1 ......... void setId(int x) { ......... } void set Salary (float x) int Employee::getAge() int Employee::getId() float Employee::getSalary() Write a main routine in which you create 5 Employee objects: a, b, c, d, and e. Set the values of a, b and c as follows: Objects Age 40 41 111 112 113 Salary 30XX) 31000 32000 42 The skeleton of the main() is as follows: void main() create 4 Employee objects: a, b, c, d 1 set the values of a, b and according to the above table 1 Use copy constructor to assign the content of object a to the content of objecte // print out the contents of a and e to show they are the same # Use "-"operator to assign the content of object b to the content of object d // print out the contents of b and d to show they are the same Il create an output file name: "output.txt" // output the contents of d and e to the file, "output.txt" You should open "output.txt" with a text editor and create a screenshot to show its contents

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 Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

Why We Listen?

Answered: 1 week ago