Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 2 Consider the class definition for Employee shown below. Write the implementations for the three constructors as they would be written in the implementation

QUESTION 2

Consider the class definition for Employee shown below. Write the implementations for the three constructors as they would be written in the implementation file. Assume that the parameters to the constructors are intended to initialize the similarly named member variables. Choose reasonable default values for member variables that do not have a corresponding parameter given. You may assume that any required system libraries have been included, and that "using namespace std;" is in place. Give only the function implementations.

class Employee { private: std::string name; // Employee's name int numOfServiceYears; // Employee's years of service double salary; // Employee's annual salary public: Employee(); Employee(std::string initName, int initServiceYears, double initSalary); Employee(std::string initName, double initSalary); void setName (std::string empName); void setServiceyears (int empServiceYears); void setSalary (double empSalary); // Accessor functions go here... }; 

QUESTION 3

Consider, again, the Employee class definition from the previous question. Write three accessor functions called getName, getServiceYears, and getSalary to retrieve the values of the similarly named private member variables. Write your three functions inline, as if your code is to be inserted at the location of the comment, "Accessor functions go here".

Again for the Employee class declaration, declare three Employee objects named emp1, emp2, and emp3, as they might be declared in a main function. For emp1, use the default constructor. For emp2, declare the object making use of the second constructor. For emp3, declare the object making use of the third constructor. Use any sample values for initialization. Give only the code for the variable declarations.

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

Students also viewed these Databases questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago