-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.cpp
More file actions
39 lines (31 loc) · 1.19 KB
/
Employee.cpp
File metadata and controls
39 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Fig. 12.10: Employee.cpp
// Abstract-base-class Employee member-function definitions.
// Note: No definitions are given for pure virtual functions.
#include <sstream>
#include "Employee.h" // Employee class definition
using namespace std;
// constructor
Employee::Employee(const string& first, const string& last,
const string& ssn)
: firstName(first), lastName(last), socialSecurityNumber(ssn) {}
// set first name
void Employee::setFirstName(const string& first) { firstName = first; }
// return first name
string Employee::getFirstName() const { return firstName; }
// set last name
void Employee::setLastName(const string& last) { lastName = last; }
// return last name
string Employee::getLastName() const { return lastName; }
// set social security number
void Employee::setSocialSecurityNumber(const string& ssn) {
socialSecurityNumber = ssn; // should validate
}
// return social security number
string Employee::getSocialSecurityNumber() const {
return socialSecurityNumber;
}
// toString Employee's information (virtual, but not pure virutal)
string Employee::toString() const {
return getFirstName() + " "s + getLastName() +
"\nsocial security number: "s + getSocialSecurityNumber();
}