-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13.cpp
More file actions
87 lines (78 loc) · 1.24 KB
/
13.cpp
File metadata and controls
87 lines (78 loc) · 1.24 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
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
//13.oop
#include <iostream>
#include <string>
using namespace std;
//상속과 다형성 예
class Musician //기반 클래스
{
string name;
public:
Musician(string name)
{
this->name = name;
}
void play()
{
cout << name << "랄라라" << endl;
}
void Greeting()
{
cout << "안녕하세요" << name << "입니다" << endl;
}
};
class Pianist : public Musician //기반 클래스 Musician에서 파생클래스 pianist 정의
{
public:
Pianist(string name) :Musician(name)
{
}
void Tuning()
{
cout << "도도레레미미파파솔솔" << endl;
}
};
void Test(Musician *musician);
int main()
{
Pianist *pianist = new Pianist("JSJ");
Test(pianist);
}
void Test(Musician *musician)
{
musician->Greeting();
musician->play();
}
//class Student
//{
// //멤버필드
// int num;
// string name;
// int iq;
//
//public:
// //멤버메서드
// Student(int num, string name) //생성자 메서드
// {
// this->num = num;
// this->name = name;
// this->iq = 100;
// }
// void Study()
// {
// cout << name << "학생 공부하다." << endl;
// iq++;
// }
// void View()
// {
// cout << "번호:" << num << "이름:" << name << "아이큐:" << iq << endl;
// }
//};
//
//int main()
//{
// Student *student = new Student(3, "홍길동");
// student->Study();
// student->View();
// delete student;
// return 0;
//}