-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCEmployee.h
91 lines (72 loc) · 1.91 KB
/
CEmployee.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Created by 下水道的小老鼠 on 2023/6/3.
//
#ifndef untitled_EMPLOYEE_H
#define untitled_EMPLOYEE_H
#include <cstring>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
struct BDay {
int year;
int month;
int day;
BDay(int y, int m, int d) : year(y), month(m), day(d) {}
};
class CEmployee {
private:
string _name; //姓名
string _sex; //性别
string _kind; //类型
BDay _birthday; //生日,自定义结构BDay,格式:1990-1-1
double _totalSalary; //月薪
public:
//构造函数
CEmployee(string name, string sex, string kind, BDay birthday, double totalSalary)
: _birthday(birthday), _totalSalary(totalSalary) {
_name = name;
_sex = sex;
_kind = kind;
};
//返回雇员名字
string getName() {
return _name;
}
string getSex() {
return _sex;
}
string getKind() {
return _kind;
}
BDay getBirthday() {
return _birthday;
}
//返回月薪
double getTotalSalary() const {
return _totalSalary;
}
void setBirthday(const BDay &birthday) {
_birthday = birthday;
}
void setTotalSalary(double totalSalary) {
_totalSalary = totalSalary;
}
//输出雇员基本信息
void printData() {
cout << "Name: " << _name << endl;
cout << "Sex: " << _sex << endl;
cout << "Kind: " << _kind << endl;
cout << "Birthday: " << _birthday.year << "-" << _birthday.month << "-" << _birthday.day << endl;
cout << "TotalSalary: " << _totalSalary << endl;
};
//计算雇员薪水
void computePay() {
cout << "TotalSalary: " << _totalSalary << endl;
};
//析构函数
virtual ~CEmployee() = default;
};
#endif //untitled_EMPLOYEE_H