C++/Inheritance. Any help with this would be awesome! Thank you! Design a class
ID: 3683906 • Letter: C
Question
C++/Inheritance. Any help with this would be awesome! Thank you!
Design a class named Employee. This class should keep the following information in member variables: Employee name, Employee number, and hire date.
// Specification file for the Employee class
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using namespace std;
class Employee
{
private:
// Declare the Employee name string variable here.
// Declare the Employee number string variable here.
// Declare the hireDate string variable here.
public:
// Default constructor
Employee()
{ name = ""; number = ""; hireDate = ""; }
// Define a Constructor that accepts, Name Number, and Hiredate
// Mutators
void setName(string n)
{ name = n; }
// define the setNumber(…) mutator here (See setName above as an example)
// define the setHireDate(…) mutator here
// Accessors
string getName() const
{ return name; }
// define the getNumber() accessor here
// define the getHireDate() accessor here
};
#endif
Write one or more constructors and the appropriate accessor and mutator functions for the class.
Explanation / Answer
// Specification file for the Employee class
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using namespace std;
class Employee
{
private:
string name;
string number;
string hireDate;
public:
// Default constructor
Employee()
{ name = ""; number = ""; hireDate = ""; }
// Define a Constructor that accepts, Name Number, and Hiredate
Employee(string name, string number, string date){
this->name = name;
this->number = number;
this->hireDate = date;
}
// Mutators
void setName(string n)
{ name = n; }
void setNumber(string num){
number = num;
}
void setHireDate(string date) {
hireDate = date;
}
// Accessors
string getName() const
{ return name; }
string getNumber() const
{ return number; }
string getHireDate() const
{ return hireDate; }
};
#endif
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.