Problem

Suppose that a class employeeType is derived from the class personType (see Example, in Ch...

Suppose that a class employeeType is derived from the class personType (see Example, in Chapter 1). Give examples of data and function members that can be added to the class employeeType.

Example

The most common attributes of a person are the person’s first name and last name. The typical operations on a person’s name are to set the name and print the name. The following statements define a class with these properties.

//************************************************************// Author: D.S. Malik//// class personType// This class specifies the members to implementaname.//************************************************************#include using namespace std;class personType{public:void print () const;//Functiontooutput the first name and last name //in the form firstName lastName.void setName(string first, string last);//Functiontoset firstName and lastName according to the //parameters.//Postcondition: firstName = first; lastName = laststring getFirstName () const;//Functiontoreturn the first name.//Postcondition: The value of firstNameisreturned.string getLastName () const;//Functiontoreturn the last name.//Postcondition: The value of lastNameisreturned.personType ();//Default constructor//Sets firstName and lastName to null strings.//Postcondition: firstName = &“ ”; lastName = &“ ”;personType(string first, string last);//Constructor with parameters.//Sets firstName and lastName according to the parameters.//Postcondition: firstName = first; lastName = last;private:string firstName; //variable to store the first namestring lastName; //variable to store the last name};

Figure shows the UML class diagram of the class personType.

FIGURE 1-9

UML class diagram of the class personType

We now give the definitions of the member functions of the class personType.

void personType::print () const

{cout << firstName << “ ” << lastName; }void personType::setName (string first, string last){firstName = first;lastName = last;}string personType::getFirstName () const {return firstName;}string personType::getLastName () const{return lastName;}//Default constructor personType::personType (){firstName = &“ ”;lastName = &“ ”;}//Constructor with parameters personType::personType(string first, string last){firstName = first;lastName = last;}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT