Write C++ code for the following questions: a. Define a class Employee. An Emplo
ID: 3771171 • Letter: W
Question
Write C++ code for the following questions:
a. Define a class Employee. An Emploee has employee number, name, dateof birth, address, phone number and salary level (such as A1, B2, C3, etc.). Declare a mutator function that can change all data members’ values. Declare an accessor function for getting the employee number.
b. Implement the member functions that you declared in the question a. above, just outside your class definition.
c. Write a fragment of code to declare an Employee instance. Set the new values for the Employee object and print out its employee number. The newvalues are up to you.
this is a c++ question.
Explanation / Answer
Here is the code for you. If you have any further queries, just get back to me.
#include <iostream>
using namespace std;
class Employee
{
int employeeNumber;
string name;
string dateOfBirth;
string address;
int phoneNumber;
string salaryLevel;
public:
void setData(int eno, string nm, string dob, string add, int phNo, string sL);
int getEmployeeNumber();
};
void Employee::setData(int eno, string nm, string dob, string add, int phNo, string sL)
{
employeeNumber = eno;
name = nm;
dateOfBirth = dob;
address = add;
phoneNumber = phNo;
salaryLevel = sL;
}
int Employee::getEmployeeNumber()
{
return employeeNumber;
}
int main()
{
Employee e;
e.setData(1234, "Kumar", "12/Dec/2015", "Alaska.US.", 12345, "A2");
cout<<"The employee number of e is: "<<e.getEmployeeNumber()<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.