docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: cpp-constructors-overloading
|
||||
title: "C++ Constructor Overloading"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["multiple constructors", "default vs parameterized constructor", "C++ 생성자 오버로딩"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop", "constructors", "overloading"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_constructors_overloading.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Constructor Overloading]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same function-overloading rule from the Functions section applies directly to constructors — since a constructor IS a function (just an unusually-named one), having multiple constructors with different parameter counts/types is simply function overloading applied to the ONE function every class automatically calls at creation time, letting `Car car1;` (defaults) and `Car car2("BMW", "X5");` (custom values) coexist as calls to the SAME class's two constructors. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Constructor overloading** — having MORE THAN ONE constructor in a class, each differentiated by parameter count/type — the same rule as regular function overloading. [S1]
|
||||
- **Default (no-argument) constructor + parameterized constructor coexisting** — one constructor sets fallback/default values, another accepts custom values; the compiler picks based on how the object is created. [S1]
|
||||
- **Why use it** — flexibility when creating objects, setting default OR custom values, reducing repetitive code. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Two coexisting constructors — no-arg (defaults) and 2-arg (custom): `class Car { public: string brand; string model; Car() { brand = "Unknown"; model = "Unknown"; } Car(string b, string m) { brand = b; model = m; } };`. [S1]
|
||||
- Calling both forms in the same program: `Car car1; // uses defaults: "Unknown" "Unknown" Car car2("BMW", "X5"); // uses custom values`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). Function Overloading 챕터의 원리가 생성자에도 그대로 적용됨이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
브랜드/모델을 지정하지 않으면 "Unknown"으로, 지정하면 그 값으로 초기화되는 Car 클래스 예제가 기본값과 커스텀 값을 모두 지원하는 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two overloaded constructors — one providing defaults, one accepting custom values (C++):
|
||||
```cpp
|
||||
class Car {
|
||||
public:
|
||||
string brand;
|
||||
string model;
|
||||
Car() { // no-argument constructor: defaults
|
||||
brand = "Unknown";
|
||||
model = "Unknown";
|
||||
}
|
||||
Car(string b, string m) { // parameterized constructor: custom
|
||||
brand = b;
|
||||
model = m;
|
||||
}
|
||||
};
|
||||
int main() {
|
||||
Car car1; // "Unknown" "Unknown"
|
||||
Car car2("BMW", "X5"); // "BMW" "X5"
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Constructors]], [[CPP Access Specifiers]], [[CPP Function Overloading]]
|
||||
- **참조 맥락:** 생성자 섹션 마지막 — 접근 지정자 및 캡슐화(Access Specifiers & Encapsulation) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Constructor Overloading — https://www.w3schools.com/cpp/cpp_constructors_overloading.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Constructor Overloading" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user