-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee.cpp
46 lines (34 loc) · 1.02 KB
/
Employee.cpp
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
40
41
42
43
44
45
46
#include <ostream>
#include <string>
#include "Definitions.h"
int Employee::numOfEmployeeThatConstructed = 1;
//constructors:
Employee::Employee(const std::string& description): id(Employee::numOfEmployeeThatConstructed){
Employee::numOfEmployeeThatConstructed++;
this->description = description;
}
Employee::Employee(const Employee& other): id(other.id){
//copy c'tor, for the clone method
this->description = other.description;
}
Employee::~Employee(){
//d'tor
}
int Employee::getID() const{
return this->id;
}
const std::string& Employee::getDescription() const{
return this->description;
}
void Employee::setDescription(const std::string& description) {
this->description = description;
}
std::ostream& operator<<(std::ostream& out, const Employee& toPrint) {
//operator << for printing employee by run-time
toPrint.print(out);
return out;
}
void Employee::print(std::ostream& out) const {
//method for printing the id of the employee
out << "ID = " << this->id << ",";
}