-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBai60.cpp
More file actions
61 lines (48 loc) · 1.03 KB
/
Bai60.cpp
File metadata and controls
61 lines (48 loc) · 1.03 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Đa hình trong C++
- Đa hình tại thời điểm biên dịch hay compile time polimophirm:
Thể hiện ở việc nạp chồng hàm, nạp chồng toán tử.
- Đa hình tại thời điểm chương trình chạy hay runtime polimophirm:
Thể hiện ở việc ghi đè các phương thức của lớp cha.
- Lesson 60: function overloading
- Lesson 61: operator overloading
- Lesson 62: function overriding
*/
#include <iostream>
using namespace std;
class Caculator {
public:
int sum(int a, int b) {
return a + b;
}
float sum(float a, float b) {
return a + b;
}
long sum(long a, long b) {
return a + b;
}
float sum(int a, float b) {
return a + b;
}
float sum(float a, int b) {
return a + b;
}
int sum(int* a, size_t size) {
int s = 0;
for (size_t i = 0; i < size; i++)
{
s += a[i];
}
return s;
}
};
class Payment {
public:
};
int main() {
Caculator c;
cout << c.sum(100, 200) << endl;
cout << c.sum(100, 25.25f) << endl;
cout << c.sum(25.0f, 30.0f) << endl;
return 0;
}