forked from thantrieu/C-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBai57.cpp
104 lines (86 loc) · 1.72 KB
/
Bai57.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
Kế thừa trong C++
*/
#include <iostream>
#include <string>
using namespace std;
class Person {
string firstName;
string lastName;
string id;
public:
Person();
Person(string id);
Person(string id, string first, string last);
string getId();
string getFirstName();
string getLastName();
string fullName();
};
Person::Person() {
firstName = "";
lastName = "";
id = "";
}
Person::Person(string id) {
Person();
this->id = id;
}
Person::Person(string id, string first, string last) {
this->id = id;
this->lastName = last;
this->firstName = first;
}
string Person::fullName() {
return this->firstName + " " + this->lastName;
}
string Person::getId() {
return id;
}
string Person::getFirstName() {
return firstName;
}
string Person::getLastName() {
return lastName;
}
class Student : public Person {
string studentID;
float mark;
float fee;
public:
Student();
Student(string, float, float);
Student(string, string, string, string, float, float);
void study(string);
void payFee(float);
void doExamp(string);
void showInfo();
};
Student::Student(string id, string first, string last,
string sId, float mark, float fee) : Person(id, first, last) {
this->studentID = sId;
this->mark = mark;
this->fee = fee;
}
void Student::showInfo() {
cout << "ID: " << getId() << endl;
cout << "Full name: " << fullName() << endl;
cout << "Student ID: " << studentID << endl;
cout << "Mark: " << mark << endl;
}
class Employee : public Person {
string eID;
float sallary;
string role;
public:
Employee();
Employee(string, float, string);
void doHisWork();
void goToWorkSpace();
bool getPayment();
};
int main() {
Student s("12345485", "Than", "Trieu", "B20DCCN123", 3.36f, 20.5f);
s.showInfo();
return 0;
}