File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ enum Status {
4
+ HIDUP,
5
+ MENINGGAL
6
+ };
7
+
8
+ namespace {
9
+
10
+ class Manusia {
11
+ private:
12
+ std::string name;
13
+ int age;
14
+ char gender;
15
+ Status status;
16
+
17
+ std::string meninggal = " alm. " ;
18
+
19
+ public:
20
+ Manusia (Status _status){
21
+ std::cout << " (obj) manusia dibuat" << std::endl;
22
+ status = _status;
23
+ }
24
+
25
+ void aturnama (std::string _name){
26
+ (status == MENINGGAL) ? name = meninggal + _name : name = _name;
27
+ }
28
+
29
+ void aturumur (int _age) {
30
+ age = _age;
31
+ }
32
+
33
+ void aturjeniskelamin (char _gender) {
34
+ gender = _gender;
35
+ }
36
+
37
+ std::string ambilnama () {
38
+ return name;
39
+ }
40
+
41
+ int ambilumur () {
42
+ return age;
43
+ }
44
+
45
+ char ambiljeniskelamin () {
46
+ return gender;
47
+ }
48
+
49
+ ~anusiaM () {
50
+ std::cout << " (obj) manusia dihapus" << std::endl;
51
+ }
52
+ };
53
+ };
54
+
55
+ int main () {
56
+ using namespace std ;
57
+
58
+ cout << " CPP Teaching Copyright (C) 2022 EmptyWork" << std::endl;
59
+
60
+ ::Manusia jason (MENINGGAL);
61
+
62
+ jason.aturnama (" Jason Aldo Amluina" );
63
+ jason.aturumur (23 );
64
+ jason.aturjeniskelamin (' P' );
65
+
66
+ cout << " Nama\t\t\t : " << jason.ambilnama () << std::endl;
67
+ cout << " Umur\t\t\t : " << jason.ambilumur () << std::endl;
68
+ cout << " Jenis Kelamin (P/W)\t : " << jason.ambiljeniskelamin () << std::endl;
69
+
70
+ }
You can’t perform that action at this time.
0 commit comments