The two header files below describe the interface of the base class Person and its derived class Empolyee, respectively. Please implement all the functions declared in these two header files in their corresponding .cpp files. 1. Header file: Person.h #ifndef Person_h #define Person_h   #include #include #include   using namespace std;   class Person{ public:     //******************Note*********     //This interface is by no means complete.  Please feel free to     // add more functions if needed. The test cases however will only     // test the following functions.       virtual ~Person();     Person(); //0->SSN, "na"->name, "personal@"->personalEmail, 10->cntPlaces, allocate space to placesVisited and initializes each place to "unknown"     Person operator=(const Person& rhs );  // **Minor revision**: changes the return mechanism from by-reference to by-value     //copy constructor     Person( const Person &clone );       string getPlace(int i) const; //return the i-th place in the placesVisited array if i is valid; otherwise return "out-of-boundary".       virtual string getEmail() const; //return personalEmail     virtual void setEmail( string new_email); //new_email-->personalEmail     virtual string getTypeOfObj() const; //return "Person"     private:     int SSN;     string name;     string personalEmail;       string *placesVisited;     int cntPlaces; //companion variable of the above pointer };     #endif /* Person_h */ 2. Header file: Employee.h #ifndef Employee_h #define Employee_h   #include "Person.h"   class Employee:public Person { private:     string work_email;     double salary;     double *sal_change_rates;     int    cnt_sal_changes; public:     virtual ~Employee();     Employee(); //0.0->salary, 10->cnt_sal_changes, "work@"->work_email, sal_change_rates: allocate memory to hold 10 doubles, each of which has an initial value of 0.0     Employee( const Employee& clone);     Employee operator=(const Employee& rhs );       double getChangeRate( int i) const;////return the i-th rate in the sal_change_rates array if i is valid; otherwise return -1.00       virtual string getEmail() const; //return work_email     virtual void setEmail( string new_email); //new_email-->work_email     virtual string getTypeOfObj() const; //return "Employee" };   //see below for more details about this function. void mixedArray( Person** &arrayPersonEmp, int numPersons, int numEmployees);   //see below for more details about this function. void deleteMixedArray(Person** &arrayPersonEmp, int size );   #endif /* Employee_hpp */ Notice that Employee.h contains two stand-alone functions. The first one void mixedArray( Person** &arrayPersonEmp, int numPersons, int numEmployees); The first parameter of this function is an array of Person pointers (i.e., Person *). This function is going to first allocate an array of (numPersons + numEmployees ) Person pointers. Next, for each of the first numPersons pointers on this array, say arrayPersonEmp[ i ], this function will create a Person object using the new operator and make it the pointee of arrayPersonEmp[ i ]. Furthermore, it will call Person's setEmail() member function to set each newly created Person object's personalEmail to personal@gmail.com. Finally, for each of the next numEmployees pointers on this array, say arrayPersonEmp[ j ], this function will create an Employee object using the new operator and make it the pointee of arrayPersonEmp[ j ]. Similarly, it will call Employee's setEmail() member function to set each newly created Employee object's work_email to work@gmail.com. For example, if numPersons=12 and numEmployees=10, this function will result in the following: arrayPersonEmp will be an array of 22 Person pointers each of the first 12 Person pointers' pointees will be a Person object. Each Person object's personalEmail will be personal@gmail.com each of the next 10 Person pointers' pointees will be an Employee object. Each Employee object's work_email will be work@gmail.com. Good to know: the following statement will make p point to a single Person object: Person *p = new Person; The second standalone function is void deleteMixedArray(Person** &arrayPersonEmp, int size ); This function is going to deallocate the space held by arrayPersonEmp, which is an array of size Person pointers. Each of such Person pointers has a dynamically allocated pointee, which is either a Person object or an Employee one. Your responsibility in this coding lab is to implement the following three program files: Person.cpp: implement all the member functions declared in Person.h Employee.cpp: implement all the member functions and the two stand-alone functions declared in Employee.h testPersonEmployee.cpp: test your Person and Employee ADTs and the two stand-alone functions.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The two header files below describe the interface of the base class Person and its derived class Empolyee, respectively. Please implement all the functions declared in these two header files in their corresponding .cpp files.

1. Header file: Person.h

#ifndef Person_h

#define Person_h

 

#include <iostream>

#include <string>

#include <new>

 

using namespace std;

 

class Person{

public:

    //******************Note*********

    //This interface is by no means complete.  Please feel free to

    // add more functions if needed. The test cases however will only

    // test the following functions.

 

    virtual ~Person();

    Person(); //0->SSN, "na"->name, "personal@"->personalEmail, 10->cntPlaces, allocate space to placesVisited and initializes each place to "unknown"

    Person operator=(const Person& rhs );  // **Minor revision**: changes the return mechanism from by-reference to by-value

    //copy constructor

    Person( const Person &clone );

 

    string getPlace(int i) const; //return the i-th place in the placesVisited array if i is valid; otherwise return "out-of-boundary".

 

    virtual string getEmail() const; //return personalEmail

    virtual void setEmail( string new_email); //new_email-->personalEmail

    virtual string getTypeOfObj() const; //return "Person"

 

 

private:

    int SSN;

    string name;

    string personalEmail;

 

    string *placesVisited;

    int cntPlaces; //companion variable of the above pointer

};

 

 

#endif /* Person_h */

2. Header file: Employee.h

#ifndef Employee_h

#define Employee_h

 

#include "Person.h"

 

class Employee:public Person

{

private:

    string work_email;

    double salary;

    double *sal_change_rates;

    int    cnt_sal_changes;

public:

    virtual ~Employee();

    Employee(); //0.0->salary, 10->cnt_sal_changes, "work@"->work_email, sal_change_rates: allocate memory to hold 10 doubles, each of which has an initial value of 0.0

    Employee( const Employee& clone);

    Employee operator=(const Employee& rhs );

 

    double getChangeRate( int i) const;////return the i-th rate in the sal_change_rates array if i is valid; otherwise return -1.00

 

    virtual string getEmail() const; //return work_email

    virtual void setEmail( string new_email); //new_email-->work_email

    virtual string getTypeOfObj() const; //return "Employee"

};

 

//see below for more details about this function.

void mixedArray( Person** &arrayPersonEmp, int numPersons, int numEmployees);

 

//see below for more details about this function.

void deleteMixedArray(Person** &arrayPersonEmp, int size );

 

#endif /* Employee_hpp */

Notice that Employee.h contains two stand-alone functions. The first one

void mixedArray( Person** &arrayPersonEmp, int numPersons, int numEmployees);

The first parameter of this function is an array of Person pointers (i.e., Person *).

  • This function is going to first allocate an array of (numPersons + numEmployees ) Person pointers.
  • Next, for each of the first numPersons pointers on this array, say arrayPersonEmp[ i ], this function will create a Person object using the new operator and make it the pointee of arrayPersonEmp[ i ]. Furthermore, it will call Person's setEmail() member function to set each newly created Person object's personalEmail to personal@gmail.com.
  • Finally, for each of the next numEmployees pointers on this array, say arrayPersonEmp[ j ], this function will create an Employee object using the new operator and make it the pointee of arrayPersonEmp[ j ]. Similarly, it will call Employee's setEmail() member function to set each newly created Employee object's work_email to work@gmail.com.

For example, if numPersons=12 and numEmployees=10, this function will result in the following:

  • arrayPersonEmp will be an array of 22 Person pointers
  • each of the first 12 Person pointers' pointees will be a Person object. Each Person object's personalEmail will be personal@gmail.com
  • each of the next 10 Person pointers' pointees will be an Employee object. Each Employee object's work_email will be work@gmail.com.

Good to know: the following statement will make p point to a single Person object:

Person *p = new Person;

The second standalone function is

void deleteMixedArray(Person** &arrayPersonEmp, int size );

This function is going to deallocate the space held by arrayPersonEmp, which is an array of size Person pointers. Each of such Person pointers has a dynamically allocated pointee, which is either a Person object or an Employee one.

Your responsibility in this coding lab is to implement the following three program files:

  • Person.cpp: implement all the member functions declared in Person.h
  • Employee.cpp: implement all the member functions and the two stand-alone functions declared in Employee.h
  • testPersonEmployee.cpp: test your Person and Employee ADTs and the two stand-alone functions.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY