We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f8f5a5a commit 4f6c2cdCopy full SHA for 4f6c2cd
_posts/2024-06-29-[부동산]-거래량.md
@@ -0,0 +1,49 @@
1
+---
2
+title: "[Programming] C++ 상속"
3
+date: 2024-06-29 18:32:30 +0800
4
+categories: [Real Estate, C++]
5
+tags: [c++]
6
7
+
8
+# 상속
9
10
+- 상속 문법 사용하기
11
12
+ - 공통의 특징을 모은 클래스를 설계한다.
13
14
+ ```cpp
15
+ class Person
16
+ {
17
+ std::string name;
18
+ int age;
19
+ };
20
21
+ class Professor : public Person
22
23
+ int major;
24
25
26
+ class Student : public Person
27
28
+ int id;
29
30
31
+ int main ()
32
33
+ Professor p;
34
+ Student s;
35
+ }
36
+ ```
37
38
+ - 한 클래스가 다른 클래스에서 정의된 속성들(데이터, 함수)를 이어 받아서 사용하는 것
39
+ - 이미 정의도니 클래스를 기반으로 새로운 클래스 설계
40
+ - S/W의 재사용성 지원
41
42
+- 상속 문법의 장점
43
44
+ - 코드의 중복을 막을 수 있다.
45
+ - 상속을 통해서 기존 클래스에 새로운 특징을 추가한 새로운 타입의 설계
46
47
+- protected
48
49
+ - 외부에서는 접근할 수 없지만, 파생클래스에서는 접근할 수 있는 멤버
0 commit comments