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,223 @@
|
||||
---
|
||||
id: cpp-tutorial-index
|
||||
title: "C++ Tutorial"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["C++ Tutorial", "C++ MOC", "Topic_CPP index", "C++ 목차"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.90
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "moc", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/default.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C++ Tutorial]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Map of Content (MOC) for the W3Schools C++ Tutorial — the root that links every core C++ knowledge page in this topic folder. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- This folder (`Topic_CPP`) wikifies the C++ programming language tutorial, one knowledge page per document, in P-Reinforce v3.1 format — same convention as `Topic_C` / `Topic_Java` / `Topic_PHP` / `Topic_Python` / `Topic_SQL` / `Topic_W3CSS` / `Topic_HTML` / `Topic_CSS` / `Topic_JavaScript`. [S1]
|
||||
- **Scope**: tutorial + "Learning by examples" pages only. **Excluded**: `cpp_challenges_*` (12 code-challenge pages), `cpp_compiler`/`cpp_exam`/`cpp_examples`/`cpp_exercises`/`cpp_practice`/`cpp_projects`/`cpp_quiz`/`cpp_real_life_examples`/`cpp_study_plan`/`cpp_syllabus` (meta/index pages), `cpp_ref_*` (10 reference-dump pages: algorithm/cstring/ctime/fstream/iostream/keywords/math/reference/string/vector), `cpp_howto_*` (2 pages, reserved for the separate HOW TO category later in the series). [S1]
|
||||
- **Progress:** **116 of 116 planned docs complete — C++ category done.** [S1]
|
||||
- Every page roots its Knowledge Graph back to this `[[C++ Tutorial]]` node.
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
|
||||
### Basics
|
||||
- [[CPP Intro]] ✅
|
||||
- [[CPP Get Started]] ✅
|
||||
- [[CPP Syntax]] ✅
|
||||
- [[CPP Statements]] ✅
|
||||
- [[CPP Comments]] ✅
|
||||
- [[CPP Output]] ✅
|
||||
- [[CPP Output Numbers]] ✅
|
||||
- [[CPP New Lines]] ✅
|
||||
|
||||
### Variables
|
||||
- [[CPP Variables]] ✅
|
||||
- [[CPP Variables Identifiers]] ✅
|
||||
- [[CPP Variables Constants]] ✅
|
||||
- [[CPP Variables Multiple]] ✅
|
||||
- [[CPP Variables RealLife]] ✅
|
||||
|
||||
### Data Types
|
||||
- [[CPP Data Types]] ✅
|
||||
- [[CPP Data Types Numeric]] ✅
|
||||
- [[CPP Data Types Bool]] ✅
|
||||
- [[CPP Data Types Char]] ✅
|
||||
- [[CPP Data Types String]] ✅
|
||||
- [[CPP Data Types RealLife]] ✅
|
||||
|
||||
### Operators
|
||||
- [[CPP Operators]] ✅
|
||||
- [[CPP Operators Arithmetic]] ✅
|
||||
- [[CPP Operators Assignment]] ✅
|
||||
- [[CPP Operators Comparison]] ✅
|
||||
- [[CPP Operators Logical]] ✅
|
||||
- [[CPP Operators Precedence]] ✅
|
||||
|
||||
### Strings
|
||||
- [[CPP Strings]] ✅
|
||||
- [[CPP Strings Access]] ✅
|
||||
- [[CPP Strings Concat]] ✅
|
||||
- [[CPP Strings Cstyle]] ✅
|
||||
- [[CPP Strings Esc]] ✅
|
||||
- [[CPP Strings Input]] ✅
|
||||
- [[CPP Strings Length]] ✅
|
||||
- [[CPP Strings Namespace]] ✅
|
||||
- [[CPP Strings Numbers]] ✅
|
||||
|
||||
### Math
|
||||
- [[CPP Math]] ✅
|
||||
|
||||
### Booleans
|
||||
- [[CPP Booleans]] ✅
|
||||
- [[CPP Booleans Expressions]] ✅
|
||||
- [[CPP Booleans RealLife]] ✅
|
||||
|
||||
### Conditions
|
||||
- [[CPP Conditions]] ✅
|
||||
- [[CPP Conditions Else]] ✅
|
||||
- [[CPP Conditions ElseIf]] ✅
|
||||
- [[CPP Conditions Shorthand]] ✅
|
||||
- [[CPP Conditions Logical]] ✅
|
||||
- [[CPP Conditions Nested]] ✅
|
||||
- [[CPP Conditions RealLife]] ✅
|
||||
|
||||
### Switch
|
||||
- [[CPP Switch]] ✅
|
||||
|
||||
### Loops
|
||||
- [[CPP While Loop]] ✅
|
||||
- [[CPP While Loop RealLife]] ✅
|
||||
- [[CPP Do While Loop]] ✅
|
||||
- [[CPP For Loop]] ✅
|
||||
- [[CPP For Loop Foreach]] ✅
|
||||
- [[CPP For Loop Nested]] ✅
|
||||
- [[CPP For Loop RealLife]] ✅
|
||||
- [[CPP Break]] ✅
|
||||
|
||||
### Arrays
|
||||
- [[CPP Arrays]] ✅
|
||||
- [[CPP Arrays Size]] ✅
|
||||
- [[CPP Arrays Loop]] ✅
|
||||
- [[CPP Arrays Multi]] ✅
|
||||
- [[CPP Arrays Omit]] ✅
|
||||
- [[CPP Arrays RealLife]] ✅
|
||||
|
||||
### Structs & Enum
|
||||
- [[CPP Structs]] ✅
|
||||
- [[CPP Enum]] ✅
|
||||
|
||||
### References, Pointers & Memory
|
||||
- [[CPP References]] ✅
|
||||
- [[CPP References Memory]] ✅
|
||||
- [[CPP Pointers]] ✅
|
||||
- [[CPP Pointers Dereference]] ✅
|
||||
- [[CPP Pointers Modify]] ✅
|
||||
- [[CPP Memory Management]] ✅
|
||||
- [[CPP Memory Management New]] ✅
|
||||
|
||||
### Functions
|
||||
- [[CPP Functions]] ✅
|
||||
- [[CPP Function Param]] ✅
|
||||
- [[CPP Function Default]] ✅
|
||||
- [[CPP Function Overloading]] ✅
|
||||
- [[CPP Function Multiple]] ✅
|
||||
- [[CPP Function Return]] ✅
|
||||
- [[CPP Function RealLife]] ✅
|
||||
- [[CPP Function Array]] ✅
|
||||
- [[CPP Function Reference]] ✅
|
||||
- [[CPP Function Structures]] ✅
|
||||
- [[CPP Functions Recursion]] ✅
|
||||
- [[CPP Functions Lambda]] ✅
|
||||
|
||||
### OOP Basics
|
||||
- [[CPP OOP]] ✅
|
||||
- [[CPP Classes]] ✅
|
||||
- [[CPP Class Methods]] ✅
|
||||
|
||||
### Constructors
|
||||
- [[CPP Constructors]] ✅
|
||||
- [[CPP Constructors Overloading]] ✅
|
||||
|
||||
### Access Specifiers & Encapsulation
|
||||
- [[CPP Access Specifiers]] ✅
|
||||
- [[CPP Encapsulation]] ✅
|
||||
|
||||
### Inheritance
|
||||
- [[CPP Inheritance]] ✅
|
||||
- [[CPP Inheritance Access]] ✅
|
||||
- [[CPP Inheritance Multilevel]] ✅
|
||||
- [[CPP Inheritance Multiple]] ✅
|
||||
|
||||
### Polymorphism & Advanced OOP
|
||||
- [[CPP Polymorphism]] ✅
|
||||
- [[CPP Virtual Functions]] ✅
|
||||
- [[CPP Friend Function]] ✅
|
||||
- [[CPP Templates]] ✅
|
||||
|
||||
### Namespaces
|
||||
- [[CPP Namespaces]] ✅
|
||||
|
||||
### Scope
|
||||
- [[CPP Scope]] ✅
|
||||
|
||||
### User Input & Date
|
||||
- [[CPP User Input]] ✅
|
||||
- [[CPP Date]] ✅
|
||||
|
||||
### Errors & Debugging
|
||||
- [[CPP Errors]] ✅
|
||||
- [[CPP Exceptions]] ✅
|
||||
- [[CPP Input Validation]] ✅
|
||||
- [[CPP Debugging]] ✅
|
||||
|
||||
### Files
|
||||
- [[CPP Files]] ✅
|
||||
|
||||
### Data Structures (STL)
|
||||
- [[CPP Data Structures]] ✅
|
||||
- [[CPP Vectors]] ✅
|
||||
- [[CPP List]] ✅
|
||||
- [[CPP Stacks]] ✅
|
||||
- [[CPP Queues]] ✅
|
||||
- [[CPP Deque]] ✅
|
||||
- [[CPP Sets]] ✅
|
||||
- [[CPP Maps]] ✅
|
||||
- [[CPP Iterators]] ✅
|
||||
- [[CPP Algorithms]] ✅
|
||||
|
||||
### Auto
|
||||
- [[CPP Auto]] ✅
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
116 knowledge documents generated across 26 sections in this batch run.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[10_Wiki]]
|
||||
- **관련 개념:** [[C Tutorial]], [[Java Tutorial]], [[CPP Intro]]
|
||||
- **참조 맥락:** SQL/Python/Java/PHP/W3.CSS/C에 이어 W3Schools 지식화 시리즈의 다음 카테고리 — C 다음의 객체지향 확장 언어.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Tutorial — https://www.w3schools.com/cpp/default.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Created C++ Tutorial MOC with scope decisions and full planned page list (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
- 2026-07-04: Topic_CPP completed — all 116 planned docs written across 26 sections (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-access-specifiers
|
||||
title: "C++ Access Specifiers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["public private protected", "default is private", "C++ 접근 지정자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop", "access-specifiers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_access_specifiers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Access Specifiers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
If a class member is declared with NO access specifier at all, it defaults to `private` — the exact behavior the earlier Classes chapter's `public:` requirement was silently protecting against — meaning every class example up to this point that used `public:` was actively OVERRIDING C++'s default visibility, not merely adding an optional label; omitting it entirely would have made those attributes inaccessible from outside. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Three access specifiers** — `public` (accessible from outside the class), `private` (NOT accessible from outside), `protected` (not accessible from outside, but accessible in INHERITED/child classes). [S1]
|
||||
- **Default access is `private`** — a class with no explicit access specifier makes ALL its members private automatically. [S1]
|
||||
- **Private-by-default as good practice** — declaring attributes `private` "as often as you can" reduces the chance of accidental misuse; this is the core ingredient of Encapsulation (next chapter). [S1]
|
||||
- **Real-life analogy** — public = front door (anyone can enter); private = locked drawer (only the owner); protected = family-only room (children/subclasses can enter, others cannot). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Mixed public/private members and the resulting access error: `class MyClass { public: int x; private: int y; }; MyClass myObj; myObj.x = 25; // Allowed myObj.y = 50; // error: y is private`. [S1]
|
||||
- Default-private class with no explicit specifier: `class MyClass { int x; int y; }; // both x and y are private by default`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **접근 지정자 생략 시 기본값은 private**: 이전 Classes 챕터에서 사용된 public:이 단순한 선택적 표시가 아니라, 생략 시 기본으로 적용되는 private를 의도적으로 override한 것이었음이 이 챕터에서 명확히 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 클래스 속성을 가능한 한 private으로 선언하는 것이 실전 코드에서 좋은 관행으로 권장되며, 이는 다음 챕터(Encapsulation)의 핵심 재료가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mixed public and private members, with the resulting compile error on private access (C++):
|
||||
```cpp
|
||||
class MyClass {
|
||||
public: // Public access specifier
|
||||
int x; // Public attribute
|
||||
private: // Private access specifier
|
||||
int y; // Private attribute
|
||||
};
|
||||
int main() {
|
||||
MyClass myObj;
|
||||
myObj.x = 25; // Allowed (public)
|
||||
myObj.y = 50; // error: y is private
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Constructors Overloading]], [[CPP Encapsulation]], [[CPP Inheritance Access]]
|
||||
- **참조 맥락:** 접근 지정자 — 캡슐화(Encapsulation) 챕터로 이어짐, protected는 상속 접근(Inheritance Access) 챕터와 직접 연결.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Access Specifiers — https://www.w3schools.com/cpp/cpp_access_specifiers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Access Specifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: cpp-algorithms
|
||||
title: "C++ Algorithms"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["<algorithm> library", "sort find C++", "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", "stl", "algorithm"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_algorithms.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Algorithms]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every `<algorithm>` function takes a RANGE (a begin/end iterator pair) instead of a container, which is why `sort(numbers.begin() + 3, numbers.end())` can sort just a SUBSET of a vector by simple iterator arithmetic — this is the payoff of the previous chapter's iterator abstraction: because `sort()`/`find()`/`min_element()` never see the container type directly, the exact same function signature works whether the range came from a full vector, a partial vector, or (implicitly) any other iterator-supporting container, something C has no equivalent for since `qsort()` needs a raw array pointer + element count instead of a reusable "range" concept. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`<algorithm>` header** — required for all functions in this chapter (`sort`, `find`, `upper_bound`, `min_element`, `max_element`, `copy`, `fill`). [S1]
|
||||
- **`sort(begin, end)`** — sorts a range in ascending order by default (alphabetically for strings, numerically for ints); reversible via `rbegin()`/`rend()` instead of `begin()`/`end()`. [S1]
|
||||
- **Partial-range sort** — `sort(numbers.begin() + 3, numbers.end())` sorts only from the 4th element onward, leaving earlier elements untouched — only possible because the function operates on an iterator range, not "the whole container." [S1]
|
||||
- **`find(begin, end, value)`** — returns an iterator to the first match (or `end()` if not found, implied by the general iterator convention). [S1]
|
||||
- **`upper_bound(begin, end, value)`** — finds the first element GREATER than `value`; REQUIRES the range to already be sorted, since it relies on binary-search-like assumptions. [S1]
|
||||
- **`min_element(begin, end)` / `max_element(begin, end)`** — return an iterator to the smallest/largest element in the range. [S1]
|
||||
- **`copy(src_begin, src_end, dest_begin)`** — copies a range of elements into another container starting at `dest_begin`; the destination must already have enough space allocated (e.g. `vector<int> copiedNumbers(6);`). [S1]
|
||||
- **`fill(begin, end, value)`** — overwrites every element in the range with `value`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Ascending sort: `sort(cars.begin(), cars.end());` — strings sort alphabetically, ints sort numerically. [S1]
|
||||
- Descending sort via reverse iterators: `sort(numbers.rbegin(), numbers.rend());`. [S1]
|
||||
- Search: `auto it = find(numbers.begin(), numbers.end(), 3);` finds the value 3. [S1]
|
||||
- Sorted-data search: `sort(numbers.begin(), numbers.end()); auto it = upper_bound(numbers.begin(), numbers.end(), 5);` — must sort FIRST, since `upper_bound` assumes sorted input. [S1]
|
||||
- Min/max: `auto it = min_element(numbers.begin(), numbers.end());` / `auto it = max_element(numbers.begin(), numbers.end());`. [S1]
|
||||
- Copy: `vector<int> copiedNumbers(6); copy(numbers.begin(), numbers.end(), copiedNumbers.begin());`. [S1]
|
||||
- Fill: `vector<int> numbers(6); fill(numbers.begin(), numbers.end(), 35);` sets all 6 elements to 35. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **범위(iterator pair) 기반 설계가 부분 정렬을 가능하게 함**: C의 `qsort()`는 배열 포인터와 전체 요소 개수를 받아야 했지만, C++의 `sort()`는 begin/end iterator만 받으므로 `numbers.begin() + 3`처럼 iterator 연산만으로 컨테이너의 일부 구간만 정렬할 수 있다는 점이 확인됨 — 이는 이전 챕터(Iterators)에서 확립된 범위 추상화의 직접적인 활용 사례. [S1]
|
||||
- **`upper_bound()`는 정렬 전제 조건이 있음**: `find()`나 `min_element()`와 달리 `upper_bound()`는 정렬되지 않은 데이터에 사용하면 올바른 결과를 보장하지 않으며, 원문도 반드시 먼저 `sort()`를 호출한 뒤 사용하도록 명시함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
정렬되지 않은 정수 vector를 먼저 sort()로 정렬한 뒤 upper_bound()로 특정 값보다 큰 첫 원소를 찾는 2단계 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Partial-range sort and sorted-precondition search (C++):
|
||||
```cpp
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
vector<int> numbers = {1, 7, 3, 5, 9, 2};
|
||||
|
||||
sort(numbers.begin() + 3, numbers.end()); // sorts only 5,9,2 -> leaves 1,7,3 untouched
|
||||
|
||||
sort(numbers.begin(), numbers.end()); // must sort first...
|
||||
auto it = upper_bound(numbers.begin(), numbers.end(), 5); // ...for upper_bound to be valid
|
||||
|
||||
auto smallest = min_element(numbers.begin(), numbers.end());
|
||||
auto largest = max_element(numbers.begin(), numbers.end());
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Iterators]], [[CPP Vectors]], [[CPP Data Structures]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션의 마지막 챕터 — Auto 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Algorithms — https://www.w3schools.com/cpp/cpp_algorithms.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Algorithms" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-arrays
|
||||
title: "C++ Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array declaration", "string arrays", "C++ 배열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "arrays"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ arrays can directly hold `string` elements (`string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};`) — something C could never do without manually nesting `char` arrays inside an outer array — meaning C++'s richer `string` type extends all the way into array element types, letting arrays of text behave as naturally as arrays of numbers. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Array declaration with size** — `type arrayName[size];` reserves space for `size` elements. [S1]
|
||||
- **Array literal initialization** — `{val1, val2, ...}` fills the array at declaration time. [S1]
|
||||
- **Zero-based indexing** — `[0]` is the first element. [S1]
|
||||
- **Mutable elements** — any element can be reassigned by index after creation. [S1]
|
||||
- **Arrays of `string`** — unlike C (which needs nested char arrays for text arrays), C++ arrays can hold `string` elements directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaring a string array with a literal: `string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};`. [S1]
|
||||
- Accessing an element: `cout << cars[0]; // Volvo`. [S1]
|
||||
- Modifying an element: `cars[0] = "Opel"; cout << cars[0]; // Now outputs Opel instead of Volvo`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++ 배열은 string을 직접 담을 수 있음**: C에서는 문자열 배열을 만들려면 char 배열들을 중첩해야 했지만, C++에서는 string cars[4] = {...}처럼 배열 원소로 string을 직접 사용할 수 있다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 브랜드 목록을 string 배열로 다루는 예제가 텍스트 데이터를 배열로 관리하는 실전 활용의 기초다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A string array — a text-array construction impossible directly in C (C++):
|
||||
```cpp
|
||||
string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
cars[0] = "Opel";
|
||||
cout << cars[0]; // Opel
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Break]], [[CPP Arrays Size]], [[C Arrays]]
|
||||
- **참조 맥락:** 배열 섹션 첫 챕터 — 배열 크기(Arrays Size) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Arrays — https://www.w3schools.com/cpp/cpp_arrays.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-arrays-loop
|
||||
title: "C++ Arrays and Loops"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["loop through array", "foreach loop arrays", "C++ 배열 반복문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "arrays", "loops", "foreach"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_loop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Arrays and Loops]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The for-each loop's element type must match the array's element type EXACTLY — `for (int num : myNumbers)` for an int array, `for (string car : cars)` for a string array — meaning unlike the traditional indexed loop (which works identically regardless of array type since it only manipulates an integer index), the for-each loop's syntax itself changes shape depending on what the array stores. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Traditional indexed loop** — `for (int i = 0; i < size; i++) { arr[i] ... }` works the same regardless of array element type. [S1]
|
||||
- **For-each loop (C++11+)** — `for (type var : arrayName)`, used EXCLUSIVELY for looping through elements in an array or other data structures (vectors, lists). [S1]
|
||||
- **Type-matched for-each declaration** — the loop variable's declared type must match the array's element type (`int` for an int array, `string` for a string array). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Indexed loop with both index and value: `for (int i = 0; i < 5; i++) { cout << i << " = " << cars[i] << "\n"; }`. [S1]
|
||||
- For-each loop over integers: `for (int num : myNumbers) { cout << num << "\n"; }`. [S1]
|
||||
- For-each loop over strings: `for (string car : cars) { cout << car << "\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **for-each 루프는 배열 타입에 맞춰 변수 타입도 바뀜**: 인덱스 기반 루프는 배열 타입과 무관하게 항상 int i로 동일하지만, for-each 루프는 int 배열엔 int, string 배열엔 string으로 변수 타입을 맞춰야 한다는 구문상 차이가 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 인덱스와 값을 함께 출력하는 패턴이 배열 내 위치 정보가 필요한 실전 상황에서 인덱스 기반 루프의 활용 근거가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The for-each loop variable type matching the array's element type (C++):
|
||||
```cpp
|
||||
string cars[5] = {"Volvo", "BMW", "Ford", "Mazda", "Tesla"};
|
||||
for (string car : cars) {
|
||||
cout << car << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays Size]], [[CPP Arrays Multi]], [[CPP For Loop Foreach]]
|
||||
- **참조 맥락:** 배열 반복문 — 다차원 배열(Arrays Multi) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Arrays and Loops — https://www.w3schools.com/cpp/cpp_arrays_loop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arrays and Loops" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-arrays-multi
|
||||
title: "C++ Multi-Dimensional Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["2D array", "3D array", "battleship game", "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", "arrays", "multidimensional"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_multi.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Multi-Dimensional Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The Battleship mini-game demonstrates that a 2D `bool` array can serve as a complete GAME STATE representation — ship positions stored as `true`/`false` grid cells, hit-tracking done by simply flipping a cell to `false` after a hit — showing multi-dimensional arrays aren't just abstract grid storage but a natural fit for representing real interactive state that changes over a program's runtime. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multi-dimensional array** — "an array of arrays"; each additional `[]` in the declaration adds one more dimension. [S1]
|
||||
- **2D array (`type name[rows][cols]`)** — declared with two bracket pairs; initialized with nested array literals (`{ {...}, {...} }`). [S1]
|
||||
- **Dual-index access** — `letters[row][col]` addresses a specific cell; zero-based. [S1]
|
||||
- **One nested loop per dimension** — a 2D array needs 2 nested loops; a 3D array needs 3. [S1]
|
||||
- **Grids as game state** — a `bool` 2D array can model ship positions in a Battleship-style game; a hit is registered by flipping the cell's value to `false`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Creating and accessing a 2D array: `string letters[2][4] = { {"A","B","C","D"}, {"E","F","G","H"} }; cout << letters[0][2]; // "C"`. [S1]
|
||||
- A 3D array declaration and full triple-nested loop: `string letters[2][2][2] = {...}; for (i...) { for (j...) { for (k...) { cout << letters[i][j][k]; } } }`. [S1]
|
||||
- Battleship game using a 2D bool array as ship-position state: `bool ships[4][4] = { {0,1,1,0}, {0,0,0,0}, {0,0,1,0}, {0,0,1,0} }; if (ships[row][column]) { ships[row][column] = 0; hits++; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 다차원 배열 구조/접근 방식이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
4x4 격자에 배 위치를 bool 값으로 저장하고, 명중 시 해당 칸을 0으로 바꾸는 배틀십 미니게임이 원문에서 직접 실전 활용 사례로 제시됨(다차원 배열이 실제 게임 상태를 표현하는 방법). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A 2D bool array modeling ship positions, with a hit flipping the cell to false (C++):
|
||||
```cpp
|
||||
bool ships[4][4] = {
|
||||
{ 0, 1, 1, 0 },
|
||||
{ 0, 0, 0, 0 },
|
||||
{ 0, 0, 1, 0 },
|
||||
{ 0, 0, 1, 0 }
|
||||
};
|
||||
if (ships[row][column]) {
|
||||
ships[row][column] = 0; // register the hit
|
||||
hits++;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays Loop]], [[CPP For Loop Nested]], [[CPP Arrays Omit]]
|
||||
- **참조 맥락:** 다차원 배열 — 배열 크기 생략(Arrays Omit) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Multi-Dimensional Arrays — https://www.w3schools.com/cpp/cpp_arrays_multi.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Multi-Dimensional Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-arrays-omit
|
||||
title: "C++ Omit Array Size"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fixed size vs dynamic size", "vector introduction", "C++ 배열 크기 생략"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "arrays", "vectors"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_omit.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Omit Array Size]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter reveals arrays' single biggest limitation and its solution in one place — a C++ array's size is FIXED forever once created (`cars[3] = "Tesla";` on a 3-element array is an ERROR, not silent truncation), and the fix isn't a special array trick but an entirely different data structure, `vector`, whose `push_back()` grows the collection dynamically — meaning "I need to add elements later" is the signal to reach for `vector` instead of `array` from the very start of a design, not something to patch onto an array afterward. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Omitting array size at declaration** — `string cars[] = {"Volvo", "BMW", "Ford"};` lets the compiler infer the size from the initializer list; equivalent to explicitly writing `[3]`. [S1]
|
||||
- **Explicit size is "good practice"** — reduces the chance of errors, even though omitting it works. [S1]
|
||||
- **Omitting elements requires a known size** — `string cars[5];` (size specified) can be filled in later index by index; `string cars[];` (no size) causes a compile error ("array size missing"). [S1]
|
||||
- **Fixed size** — an array's size can NEVER change after creation; attempting to add a new index beyond its declared size is an error. [S1]
|
||||
- **`vector<type>`** — from `<vector>`, a RESIZABLE array; grows/shrinks dynamically via functions like `push_back()`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Size-omitted declaration inferring 3 elements: `string cars[] = {"Volvo", "BMW", "Ford"};` — equivalent to `string cars[3] = {...};`. [S1]
|
||||
- The fixed-size error case: `string cars[3] = {"Volvo", "BMW", "Ford"}; cars[3] = "Tesla"; // error — no 4th slot exists`. [S1]
|
||||
- The vector alternative that CAN grow: `vector<string> cars = {"Volvo", "BMW", "Ford"}; cars.push_back("Tesla"); // now has 4 elements`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **배열의 고정 크기 한계와 벡터라는 해법**: 배열은 생성 후 크기를 절대 바꿀 수 없어 4번째 요소를 추가하려 하면 에러가 발생하지만, <vector> 라이브러리의 vector 타입은 push_back()으로 동적으로 크기를 늘릴 수 있다는 점이 명시적으로 소개됨 — C 튜토리얼에는 없던 C++ 고유의 해법. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 요소를 나중에 추가/삭제해야 하는 상황이라면 배열 대신 벡터를 선택해야 한다는 판단 기준이 실전 설계 결정에서 핵심이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A vector growing dynamically where a fixed-size array would error (C++):
|
||||
```cpp
|
||||
#include <vector>
|
||||
vector<string> cars = {"Volvo", "BMW", "Ford"};
|
||||
cars.push_back("Tesla"); // vector can grow; a fixed array cannot
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays Multi]], [[CPP Vectors]], [[CPP Arrays RealLife]]
|
||||
- **참조 맥락:** 배열 크기 생략과 벡터 소개 — 배열 실전 예제(Arrays RealLife) 챕터로 이어짐, 벡터(Vectors) 챕터와 직접 연결.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Omit Array Size — https://www.w3schools.com/cpp/cpp_arrays_omit.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Omit Array Size" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-arrays-reallife
|
||||
title: "C++ Arrays Real-Life Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["average calculation", "find minimum", "C++ 배열 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "arrays", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Arrays Real-Life Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This example computes the array LENGTH via `sizeof(ages) / sizeof(ages[0])` but then iterates using the for-each loop (`for (int age : ages)`) — combining the sizeof-formula (needed for the average's DENOMINATOR) with the for-each style (used for the actual ITERATION) rather than picking one loop style exclusively, showing the two techniques from the Arrays Size chapter aren't mutually exclusive alternatives but tools combined based on what each specific line of code actually needs. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Average via accumulate-then-divide** — sum every element in a for-each loop, then divide by the `sizeof`-derived length. [S1]
|
||||
- **Find-minimum via self-seeded comparison** — initialize the tracking variable with the array's first element, then compare while looping through the rest (same technique as C). [S1]
|
||||
- **Mixing sizeof (for length) and for-each (for iteration)** — the two array techniques from earlier chapters combined in one program based on what each line needs. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Average calculation combining sizeof-length and for-each iteration: `int ages[8] = {20,22,18,35,48,26,87,70}; float avg, sum = 0; int length = sizeof(ages) / sizeof(ages[0]); for (int age : ages) { sum += age; } avg = sum / length;`. [S1]
|
||||
- Find-minimum via self-seeding: `int lowestAge = ages[0]; for (int age : ages) { if (lowestAge > age) { lowestAge = age; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **sizeof 공식과 for-each 루프를 함께 사용**: 배열 길이 계산에는 sizeof 공식을, 실제 순회에는 for-each를 쓰는 조합이 두 기법이 상호 배타적 대안이 아니라 상황에 맞게 함께 쓰이는 도구임을 보여줌. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
나이 목록의 평균과 최솟값을 계산하는 두 예제가 원문에서 직접 실전 활용 사례로 제시되며, sizeof 기반 length 계산과 for-each 순회 패턴을 실제 통계 계산에 결합해 적용하는 방법을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combining sizeof (for length) and the for-each loop (for iteration) in one calculation (C++):
|
||||
```cpp
|
||||
int ages[8] = {20, 22, 18, 35, 48, 26, 87, 70};
|
||||
float avg, sum = 0;
|
||||
int length = sizeof(ages) / sizeof(ages[0]);
|
||||
for (int age : ages) {
|
||||
sum += age;
|
||||
}
|
||||
avg = sum / length;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays Omit]], [[CPP Structs]], [[C Arrays RealLife]]
|
||||
- **참조 맥락:** 배열 섹션 마지막 — 구조체 및 열거형(Structs & Enum) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Arrays Real-Life Examples — https://www.w3schools.com/cpp/cpp_arrays_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arrays Real-Life Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-arrays-size
|
||||
title: "C++ Array Size"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["sizeof array", "array length formula", "foreach vs sizeof loop", "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", "arrays", "sizeof"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_size.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Array Size]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter explicitly presents THREE competing ways to loop through an array — hardcoded bound (fragile), `sizeof(arr)/sizeof(arr[0])` (robust but verbose), and the C++11 for-each loop (cleanest) — and closes by saying it's "good to know" all three because "you may encounter them all in different programs," meaning C++ codebases in the wild mix loop styles from different eras, unlike C where the sizeof-formula approach was presented as the single best practice. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`sizeof(array)`** — returns the array's TOTAL memory footprint in bytes, not element count (same C behavior). [S1]
|
||||
- **Element-count formula** — `sizeof(arr) / sizeof(arr[0])` gives the actual element count. [S1]
|
||||
- **Three loop styles for arrays** — hardcoded bound (fragile), sizeof-formula bound (robust), for-each (C++11, cleanest). [S1]
|
||||
- **All three coexist in real code** — the tutorial explicitly recommends knowing all of them since different programs use different styles. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Raw byte-size result: `int myNumbers[5] = {10, 20, 30, 40, 50}; cout << sizeof(myNumbers); // 20 (not 5)`. [S1]
|
||||
- Correct element-count formula: `int getArrayLength = sizeof(myNumbers) / sizeof(myNumbers[0]); cout << getArrayLength; // 5`. [S1]
|
||||
- Sizeof-driven loop (robust but verbose): `for (int i = 0; i < sizeof(myNumbers) / sizeof(myNumbers[0]); i++) { cout << myNumbers[i] << "\n"; }`. [S1]
|
||||
- The cleanest alternative (C++11 for-each): `for (int num : myNumbers) { cout << num << "\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **세 가지 반복 스타일이 실전에서 혼재함**: 하드코딩된 경계, sizeof 공식 기반, for-each 세 방식 모두 실제 프로그램에서 마주칠 수 있어 전부 알아두는 것이 좋다고 명시적으로 권고됨 — C 챕터가 sizeof 공식을 유일한 권장 방식으로 제시한 것과 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 세 가지 반복 스타일을 모두 이해해두는 것이 다양한 C++ 코드베이스를 읽는 실전 능력으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The cleanest way to loop through an array, introduced in C++11 (C++):
|
||||
```cpp
|
||||
int myNumbers[5] = {10, 20, 30, 40, 50};
|
||||
for (int num : myNumbers) {
|
||||
cout << num << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays]], [[CPP Arrays Loop]], [[CPP For Loop Foreach]], [[C Arrays Size]]
|
||||
- **참조 맥락:** 배열 크기 계산 공식 — 배열과 반복문(Arrays Loop) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Array Size — https://www.w3schools.com/cpp/cpp_arrays_size.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Array Size" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: cpp-auto
|
||||
title: "C++ auto"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["auto keyword C++", "type inference C++", "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", "auto", "type-inference"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_auto.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Auto]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++11's `auto` hijacks the EXACT SAME keyword C already had (`auto` is a legal C storage-class specifier meaning "automatic/local storage duration," the implicit default for every local variable) and repurposes it to mean something completely unrelated — compile-time type inference — meaning any C programmer who ever learned "auto is the default, mostly-unused storage class" must unlearn that and relearn `auto` as "let the compiler deduce my type," the same token now doing a categorically different job depending on which language's rules apply. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`auto` = compile-time type inference** — the compiler determines the variable's type from the value assigned to it, e.g. `auto x = 5;` makes `x` an `int`. [S1]
|
||||
- **Must initialize at declaration** — `auto x;` with no assigned value is illegal; the compiler needs the right-hand value to infer a type from. [S1]
|
||||
- **Type is locked in after inference** — once `auto x = 5;` fixes `x` as `int`, later reassigning a different type (`x = 9.99;`) is a compile error, exactly as if `int` had been written explicitly. [S1]
|
||||
- **Works for any type** — `int`, `float` (`5.99f`), `double` (`9.98`), `char` (`'D'`), `bool` (`true`), and `std::string` (`string("Hello")`) are all shown inferred correctly. [S1]
|
||||
- **Primary real-world use: complex types** — the tutorial notes `auto` is used sparingly for simple types (`int`, `double`) but becomes genuinely valuable for verbose/complex types like iterators and lambdas, where writing the full type out by hand is impractical. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic substitution: `auto x = 5;` behaves identically to `int x = 5;`. [S1]
|
||||
- Multi-type example: `auto myNum = 5; auto myFloatNum = 5.99f; auto myDoubleNum = 9.98; auto myLetter = 'D'; auto myBoolean = true; auto myString = string("Hello");` — each variable's true type is silently inferred (int, float, double, char, bool, std::string respectively). [S1]
|
||||
- Type-locking demonstrated: `auto x = 5; x = 10; // OK; x = 9.99; // Error`. [S1]
|
||||
- Cross-reference to prior chapters: this page explicitly calls back to iterators (`vector<string>::iterator it` shortened to `auto it`) and forward to lambdas as the chapters where `auto`'s real value shows up. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **동일 키워드, 완전히 다른 의미**: C에서 `auto`는 지역 변수의 기본 저장 기간(automatic storage duration)을 명시하는 저장 클래스 지정자로, 사실상 거의 사용되지 않는 키워드였다. C++11은 이 키워드를 재사용하되 "타입 추론"이라는 전혀 다른 의미를 부여했다는 점이 이번 챕터에서 확인됨 — 문법 토큰은 같지만 역할은 완전히 별개. [S1]
|
||||
- **한 번 추론된 타입은 고정됨**: 동적 타입 언어의 변수 재할당과 혼동하기 쉽지만, `auto`로 추론된 타입도 일반 `int`/`double` 변수와 똑같이 정적 타입 검사를 받는다는 점이 예제(`x = 9.99;` 에러)로 명확히 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Iterators 챕터에서 이미 `vector<string>::iterator it` 대신 `auto it = cars.begin();`으로 축약해 사용한 것이 `auto`의 실전 활용 사례로 원문에서 직접 역참조됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Type inference across multiple types, and the type-locking rule (C++):
|
||||
```cpp
|
||||
auto myNum = 5; // int
|
||||
auto myFloatNum = 5.99f; // float
|
||||
auto myDoubleNum = 9.98; // double
|
||||
auto myLetter = 'D'; // char
|
||||
auto myBoolean = true; // bool
|
||||
auto myString = string("Hello"); // std::string
|
||||
|
||||
auto x = 5; // x is now an int
|
||||
x = 10; // OK - still an int
|
||||
x = 9.99; // Error - can't assign a double to an int
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Iterators]], [[CPP Functions Lambda]], [[C Variables]]
|
||||
- **참조 맥락:** C++ 튜토리얼의 마지막 챕터 — Topic_CPP 전체 완료.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ auto — https://www.w3schools.com/cpp/cpp_auto.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ auto" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-booleans
|
||||
title: "C++ Booleans"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bool type", "boolalpha manipulator", "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", "booleans", "boolalpha"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_booleans.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Booleans]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`boolalpha` is explicitly NOT a data type — it's an I/O stream manipulator, a persistent SETTING that changes how `cout` displays every subsequent boolean until `noboolalpha` resets it — meaning printing `true`/`false` as words versus `1`/`0` isn't a per-call choice like a format specifier, but a stateful mode switch that affects ALL following boolean output on that stream. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`bool`** — native C++ type; `true` (1) or `false` (0). [S1]
|
||||
- **Default printing shows 1/0** — `cout << boolVar;` prints the integer representation by default. [S1]
|
||||
- **`boolalpha`** — an I/O manipulator (not a type) that switches `cout` to print `true`/`false` as WORDS instead of `1`/`0`; the setting persists for all subsequent output until reset. [S1]
|
||||
- **`noboolalpha`** — resets `cout` back to the default `1`/`0` printing behavior. [S1]
|
||||
- **Both styles are valid** — the choice between `1`/`0` and `true`/`false` display is purely stylistic. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Default 1/0 printing: `bool isCodingFun = true; cout << isCodingFun; // 1`. [S1]
|
||||
- Switching to word display: `cout << boolalpha; cout << isCodingFun; // true`. [S1]
|
||||
- Resetting back to numeric display: `cout << noboolalpha; cout << isCodingFun; // 1`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **boolalpha는 타입이 아니라 상태를 바꾸는 매니퓰레이터**: 한 번 켜면 이후의 모든 불리언 출력에 지속적으로 영향을 미치는 설정이라는 점이 명시적으로 확인됨 — noboolalpha로 초기화하기 전까지 유지됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — boolalpha/noboolalpha를 오가며 출력 스타일을 전환하는 것이 디버깅 출력의 가독성을 높이는 실전 활용이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Switching cout's boolean display mode with boolalpha, then resetting it (C++):
|
||||
```cpp
|
||||
bool isCodingFun = true;
|
||||
cout << boolalpha; // enable printing "true"/"false"
|
||||
cout << isCodingFun; // Outputs true
|
||||
cout << noboolalpha; // reset to 1/0
|
||||
cout << isCodingFun; // Outputs 1
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Math]], [[CPP Booleans Expressions]], [[C Booleans]]
|
||||
- **참조 맥락:** 불리언 섹션 첫 챕터 — 불리언 표현식(Booleans Expressions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Booleans — https://www.w3schools.com/cpp/cpp_booleans.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Booleans" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-booleans-expressions
|
||||
title: "C++ Boolean Expressions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["comparison result storage", "C++ 불리언 표현식"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "booleans", "boolean-expressions"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_booleans_expressions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Boolean Expressions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source explicitly frames boolean expressions as "the foundation of decision making in programming" — not just a data-comparison mechanism, but the literal MECHANISM by which a program "decides what to do," directly foreshadowing the entire upcoming Conditions section, which is really just boolean expressions wired into `if`/`else` branches. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Boolean expression** — code that compares values/variables and returns `1` (true) or `0` (false). [S1]
|
||||
- **Comparisons work on both literals and variables** — `cout << (x > y);` and `cout << (10 > 9);` behave identically. [S1]
|
||||
- **Storing a comparison in a bool variable** — `bool isGreater = x > y;` makes reused/complex conditions more readable. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Greater-than comparison on variables: `int x = 10; int y = 9; cout << (x > y); // 1`. [S1]
|
||||
- Equal-to comparison on a literal: `cout << (10 == 15); // 0`. [S1]
|
||||
- Storing a comparison result: `int x = 10; int y = 9; bool isGreater = x > y; cout << isGreater; // 1`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 비교 결과를 bool 변수에 저장해 재사용하는 패턴이 코드 가독성을 높이는 실전 습관으로 권장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Storing a comparison's result in a bool variable for readability (C++):
|
||||
```cpp
|
||||
int x = 10;
|
||||
int y = 9;
|
||||
bool isGreater = x > y;
|
||||
cout << isGreater; // returns 1 (true)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Booleans]], [[CPP Booleans RealLife]], [[C Booleans]]
|
||||
- **참조 맥락:** 불리언 표현식 — 불리언 실전 예제(Booleans RealLife) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Boolean Expressions — https://www.w3schools.com/cpp/cpp_booleans_expressions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Boolean Expressions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-booleans-reallife
|
||||
title: "C++ Boolean Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["voting age example", "boolean if-else preview", "C++ 불리언 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "booleans", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_booleans_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Boolean Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter upgrades a raw `1`/`0` boolean printout into an `if...else` statement using the IDENTICAL voting-age scenario and comparison from C's equivalent Booleans RealLife chapter — showing that C++'s conditional syntax (`if (myAge >= votingAge) {...} else {...}`) is a drop-in replacement for C's, with the only difference being `cout <<` instead of `printf()` inside the branches. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Raw comparison output** — `cout << (myAge >= votingAge);` shows 1 or 0, technically correct but not user-friendly. [S1]
|
||||
- **The same comparison inside `if...else`** — produces human-readable output instead of a raw 1/0. [S1]
|
||||
- **Booleans as the foundation of conditions** — explicitly stated to be the basis for ALL C++ comparisons and conditions, directly foreshadowing the Conditions section. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Raw comparison output: `int myAge = 25; int votingAge = 18; cout << (myAge >= votingAge); // 1`. [S1]
|
||||
- The same logic upgraded into an if...else: `if (myAge >= votingAge) { cout << "Old enough to vote!"; } else { cout << "Not old enough to vote."; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
투표 가능 연령(18세) 확인 로직을 raw 1/0 출력에서 if...else로 업그레이드하는 것이 이 챕터가 직접 보여주는 실전 활용 사례이자, 다음 챕터(Conditions)로의 전환점이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The same boolean comparison used inside an if...else for human-readable output (C++):
|
||||
```cpp
|
||||
int myAge = 25;
|
||||
int votingAge = 18;
|
||||
if (myAge >= votingAge) {
|
||||
cout << "Old enough to vote!";
|
||||
} else {
|
||||
cout << "Not old enough to vote.";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Booleans Expressions]], [[CPP Conditions]], [[C Booleans RealLife]]
|
||||
- **참조 맥락:** 불리언 섹션 마지막 — 조건문(Conditions) 섹션으로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Boolean Examples — https://www.w3schools.com/cpp/cpp_booleans_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Boolean Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: cpp-break
|
||||
title: "C++ Break and Continue"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["break statement", "continue statement", "loop control", "C++ break continue"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "break", "continue"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_break.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Break and Continue]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The break-in-while example places `i++` BEFORE the `if (i == 4) break;` check, deliberately different ordering from the continue-in-while example (which places `i++` inside the `if` block before `continue`) — a subtle structural detail showing that where the increment sits relative to the break/continue check must be deliberately designed per-case to avoid either skipping a value or looping forever, unlike a `for` loop where the increment is guaranteed to run automatically regardless of `continue`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`break`** — stops the loop COMPLETELY. [S1]
|
||||
- **`continue`** — skips the REST of the current iteration and jumps to the next one. [S1]
|
||||
- **Works in both `for` and `while` loops** — same semantics apply regardless of loop type. [S1]
|
||||
- **Increment placement matters in `while` loops** — unlike `for` loops (where the increment always runs), a `while` loop's increment must be manually placed correctly relative to `continue`, or the loop may infinite-loop or skip incorrectly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `break` stopping a for loop at i==4: `for (int i = 0; i < 10; i++) { if (i == 4) { break; } cout << i << "\n"; }` — prints 0,1,2,3 then stops entirely. [S1]
|
||||
- `continue` skipping just one value: `for (int i = 0; i < 10; i++) { if (i == 4) { continue; } cout << i << "\n"; }` — prints 0,1,2,3,5,6,7,8,9. [S1]
|
||||
- `break` in a while loop (increment BEFORE the break check): `int i = 0; while (i < 10) { cout << i << "\n"; i++; if (i == 4) { break; } }`. [S1]
|
||||
- `continue` in a while loop (increment INSIDE the if, before continue, to avoid an infinite loop): `int i = 0; while (i < 10) { if (i == 4) { i++; continue; } cout << i << "\n"; i++; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **while 루프에서는 증가식 위치를 직접 설계해야 함**: for 루프와 달리 while 루프는 증가식(i++)이 자동으로 실행되지 않으므로, continue를 쓸 때는 continue 이전에 반드시 i++을 넣어야 무한루프를 피할 수 있다는 점이 두 예제(break용/continue용)의 서로 다른 i++ 배치로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — while 루프에서 continue를 쓸 때 증가식을 continue 이전에 두어야 무한루프를 방지한다는 점이 실전 디버깅에서 흔히 놓치는 함정으로 시사된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Placing the increment before continue in a while loop to avoid an infinite loop (C++):
|
||||
```cpp
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
if (i == 4) {
|
||||
i++; // must increment before continue
|
||||
continue;
|
||||
}
|
||||
cout << i << "\n";
|
||||
i++;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP For Loop RealLife]], [[CPP Switch]], [[CPP Arrays]]
|
||||
- **참조 맥락:** 반복문 섹션 마지막 — 배열(Arrays) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Break and Continue — https://www.w3schools.com/cpp/cpp_break.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Break and Continue" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: cpp-class-methods
|
||||
title: "C++ Class Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["scope resolution operator", "define method outside class", "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", "methods"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_class_methods.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Class Methods]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The scope resolution operator (`ClassName::methodName`) lets a method's DECLARATION live inside the class while its DEFINITION lives entirely outside it — recommended explicitly "especially in large programs" — mirroring the exact same declaration/definition-split rationale from the earlier plain-Functions chapter, but requiring this specific `::` syntax to reconnect the standalone definition back to its owning class. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Method** — a function belonging to a class; accessed via dot syntax on an object, same as attributes. [S1]
|
||||
- **Defining inside the class** — the method's full body is written directly within the class definition. [S1]
|
||||
- **Defining outside the class** — the class only DECLARES the method's signature; the actual body is written later using `ClassName::methodName() { ... }`. [S1]
|
||||
- **Scope resolution operator (`::`)** — connects a method definition written outside the class back to its class. [S1]
|
||||
- **Methods with parameters** — work exactly like regular function parameters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Method defined inline: `class MyClass { public: void myMethod() { cout << "Hello World!"; } };`. [S1]
|
||||
- Method declared in the class, defined outside via `::`: `class MyClass { public: void myMethod(); }; void MyClass::myMethod() { cout << "Hello World!"; }`. [S1]
|
||||
- A parameterized method: `class Car { public: int speed(int maxSpeed); }; int Car::speed(int maxSpeed) { return maxSpeed; } Car myObj; cout << myObj.speed(200);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **:: 연산자가 클래스 외부 정의를 다시 연결함**: 큰 프로그램에서는 메서드를 클래스 안에서는 선언만 하고 실제 본문은 밖에서 ClassName::methodName() 형태로 정의하는 것이 권장되며, 이 :: (범위 결정 연산자)가 정의를 소속 클래스와 다시 연결한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Car 클래스의 speed() 메서드가 매개변수(maxSpeed)를 받아 그대로 반환하는 예제가 클래스 메서드의 매개변수 활용 실전 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Declaring a method inside the class, defining it outside using the scope resolution operator (C++):
|
||||
```cpp
|
||||
class Car {
|
||||
public:
|
||||
int speed(int maxSpeed); // declaration
|
||||
};
|
||||
int Car::speed(int maxSpeed) { // definition, outside the class
|
||||
return maxSpeed;
|
||||
}
|
||||
int main() {
|
||||
Car myObj;
|
||||
cout << myObj.speed(200);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Classes]], [[CPP Constructors]], [[CPP Functions Decl]]
|
||||
- **참조 맥락:** OOP Basics 섹션 마지막 — 생성자(Constructors) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Class Methods — https://www.w3schools.com/cpp/cpp_class_methods.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Class Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-classes
|
||||
title: "C++ Classes and Objects"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["class keyword", "public access specifier", "attributes", "C++ 클래스와 객체"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop", "classes"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_classes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Classes and Objects]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A C++ class LOOKS almost identical to a C struct at first glance — variables grouped inside curly braces, accessed via dot syntax, ending in a semicolon — but requires ONE extra piece C's struct never needed: the `public:` access specifier, meaning without it, class members would default to being INACCESSIBLE from outside the class, a private-by-default behavior structs don't have. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Class** — a user-defined data type; a "blueprint" for creating objects; variables inside are called ATTRIBUTES, functions are called METHODS (collectively "class members"). [S1]
|
||||
- **`class` keyword** — creates a class, e.g. `class MyClass { ... };` — ending with a semicolon, just like a struct. [S1]
|
||||
- **`public:` access specifier** — REQUIRED for members to be accessible from outside the class (covered in more depth in a later chapter). [S1]
|
||||
- **Creating an object** — `MyClass myObj;` instantiates the class; attributes are accessed via dot syntax (`myObj.myNum`). [S1]
|
||||
- **Multiple objects from one class** — each object maintains its OWN independent set of attribute values. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic class with public attributes: `class MyClass { public: int myNum; string myString; };`. [S1]
|
||||
- Creating an object and setting/reading attributes: `MyClass myObj; myObj.myNum = 15; myObj.myString = "Some text"; cout << myObj.myNum;`. [S1]
|
||||
- Two independent objects of the same class: `Car carObj1; carObj1.brand = "BMW"; Car carObj2; carObj2.brand = "Ford";` — each object's `brand` is stored separately. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **public 접근 지정자가 필수적으로 요구됨**: C의 struct와 겉모습은 비슷하지만, C++ 클래스는 멤버를 클래스 외부에서 접근하려면 public: 접근 지정자를 명시해야 한다는 점이 확인됨(기본은 private) — 이는 다음 섹션(Access Specifiers)에서 더 자세히 다뤄짐. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Car 클래스 하나로 BMW와 Ford 두 대의 서로 다른 자동차 객체를 만드는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A class with public attributes, instantiated as two independent objects (C++):
|
||||
```cpp
|
||||
class Car {
|
||||
public:
|
||||
string brand;
|
||||
string model;
|
||||
int year;
|
||||
};
|
||||
int main() {
|
||||
Car carObj1;
|
||||
carObj1.brand = "BMW";
|
||||
Car carObj2;
|
||||
carObj2.brand = "Ford";
|
||||
cout << carObj1.brand << "\n" << carObj2.brand;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP OOP]], [[CPP Class Methods]], [[C Structs]]
|
||||
- **참조 맥락:** 클래스와 객체 — 클래스 메서드(Class Methods) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Classes and Objects — https://www.w3schools.com/cpp/cpp_classes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Classes and Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-comments
|
||||
title: "C++ Comments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["single-line comments", "multi-line comments", "C++ 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_comments.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Comments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike the C tutorial, which highlighted a historical constraint (single-line `//` comments only became standard in C99), the C++ chapter presents both `//` and `/* */` as equally native from the start with no such caveat — reflecting that C++ never carried C's pre-1999 single-line-comment limitation, since C++ has supported `//` since its earliest standardization. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Single-line comments (`//`)** — text from `//` to end of line is ignored by the compiler. [S1]
|
||||
- **Multi-line comments (`/* */`)** — text between the markers is ignored, regardless of line count. [S1]
|
||||
- **Stylistic convention** — `//` for short comments, `/* */` for longer ones; entirely up to the developer. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single-line comment before code: `// This is a comment cout << "Hello World!";`. [S1]
|
||||
- Single-line comment at end of a line: `cout << "Hello World!"; // This is a comment`. [S1]
|
||||
- Multi-line comment: `/* The code below will print the words Hello World! to the screen, and it is amazing */ cout << "Hello World!";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 짧은 주석에는 //, 긴 설명에는 /* */를 쓰는 관행이 C 챕터와 동일하게 권장됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Single-line comment used to explain a line of code (C++):
|
||||
```cpp
|
||||
cout << "Hello World!"; // This is a comment
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Statements]], [[CPP Output]]
|
||||
- **참조 맥락:** 주석 문법 — 출력(Output) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Comments — https://www.w3schools.com/cpp/cpp_comments.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-conditions
|
||||
title: "C++ If ... Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["if statement", "lowercase if", "C++ 조건문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "if-statement"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP If ... Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every rule from C's `if` chapter carries over verbatim — lowercase-only `if` (uppercase `If`/`IF` errors), the same six comparison operators, and the same bool-variable-for-readability pattern — meaning C++'s conditional syntax is a direct, unmodified continuation of C's, with the only visible difference being `cout <<` replacing `printf()` inside the branches. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Six comparison conditions** — `<`, `<=`, `>`, `>=`, `==`, `!=`, identical to C. [S1]
|
||||
- **Four conditional constructs** — `if`, `else`, `else if`, `switch` — same set as C. [S1]
|
||||
- **Case-sensitive keyword** — `if` must be lowercase; `If`/`IF` produce an error. [S1]
|
||||
- **Boolean-variable readability pattern** — storing a comparison's result in a `bool` variable before using it in `if` improves readability for complex/reused conditions. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic if with variables: `int x = 20; int y = 18; if (x > y) { cout << "x is greater than y"; }`. [S1]
|
||||
- Using a boolean variable to hold the condition: `bool isGreater = x > y; if (isGreater) { cout << "x is greater than y"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 규칙임이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 복잡하거나 재사용되는 조건을 bool 변수에 미리 담아두는 패턴이 가독성 있는 조건문 작성의 실전 관행이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Storing a condition in a readable boolean variable before using it in an if statement (C++):
|
||||
```cpp
|
||||
int x = 20;
|
||||
int y = 18;
|
||||
bool isGreater = x > y;
|
||||
if (isGreater) {
|
||||
cout << "x is greater than y";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Booleans RealLife]], [[CPP Conditions Else]], [[C Conditions]]
|
||||
- **참조 맥락:** 조건문 섹션 첫 챕터 — else 문(Conditions Else) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ If ... Else — https://www.w3schools.com/cpp/cpp_conditions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ If ... Else" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-conditions-else
|
||||
title: "C++ Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["else statement", "C++ else 문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "else"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_else.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The identical time-of-day (`time < 18`) example and the identical `isDay`-naming advice from C's Else chapter reappear here unchanged — confirming that descriptive boolean naming as a pure communication device (not a behavioral change) is a language-agnostic best practice the tutorial deliberately repeats across both C and C++. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`else`** — runs a block of code when the paired `if` condition is false. [S1]
|
||||
- **Mutually exclusive branches** — exactly one of `if`/`else` executes. [S1]
|
||||
- **Descriptive boolean naming** — storing a condition in a variable like `isDay` documents its MEANING. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic if/else: `int time = 20; if (time < 18) { cout << "Good day."; } else { cout << "Good evening."; } // Outputs "Good evening."`. [S1]
|
||||
- Same logic with a descriptively-named boolean: `bool isDay = time < 18; if (isDay) { cout << "Good day."; } else { cout << "Good evening."; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
시간(time)이 18보다 작은지에 따라 "좋은 하루"/"좋은 저녁"을 출력하는 예제가 C 챕터와 동일하게 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Naming a boolean condition descriptively for readability (C++):
|
||||
```cpp
|
||||
int time = 20;
|
||||
bool isDay = time < 18;
|
||||
if (isDay) {
|
||||
cout << "Good day.";
|
||||
} else {
|
||||
cout << "Good evening.";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions]], [[CPP Conditions ElseIf]], [[C Conditions Else]]
|
||||
- **참조 맥락:** else 문 — else if 문(Conditions ElseIf) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Else — https://www.w3schools.com/cpp/cpp_conditions_else.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Else" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: cpp-conditions-elseif
|
||||
title: "C++ Else If"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["else if chain", "top to bottom evaluation", "C++ else if 문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "else-if"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_elseif.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Else If]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The first-match-wins rule (conditions checked top-to-bottom, stopping at the first true match, even if a later condition would also hold) is stated with the exact same wording and the exact same time-of-day example as C's chapter — reconfirming that C++'s `else if` chain evaluation semantics are inherited from C without modification. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`else if`** — tests a new condition only if the preceding condition(s) were false. [S1]
|
||||
- **First-match-wins evaluation** — conditions checked top to bottom; the first true condition's block runs, remaining conditions are skipped. [S1]
|
||||
- **Boolean-variable chaining** — each condition in the chain can be pre-computed into a descriptively-named bool. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Time-of-day chain: `int time = 16; if (time < 12) { cout << "Good morning."; } else if (time < 18) { cout << "Good day."; } else { cout << "Good evening."; } // Outputs "Good day."`. [S1]
|
||||
- Same chain with named booleans: `bool isMorning = time < 12; bool isDay = time < 18; if (isMorning) {...} else if (isDay) {...} else {...}`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 우선 매칭 규칙임이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 시간대에 따라 아침/낮/저녁 인사를 구분하는 것이 else if 체인의 대표적인 실전 활용 예시다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained else-if conditions evaluated top-to-bottom, stopping at the first match (C++):
|
||||
```cpp
|
||||
int time = 16;
|
||||
if (time < 12) {
|
||||
cout << "Good morning.";
|
||||
} else if (time < 18) {
|
||||
cout << "Good day.";
|
||||
} else {
|
||||
cout << "Good evening.";
|
||||
}
|
||||
// Outputs "Good day."
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions Else]], [[CPP Conditions Shorthand]], [[C Conditions ElseIf]]
|
||||
- **참조 맥락:** else if 체인 — 삼항 연산자(Conditions Shorthand) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Else If — https://www.w3schools.com/cpp/cpp_conditions_elseif.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Else If" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: cpp-conditions-logical
|
||||
title: "C++ Logical Operators in Conditions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["access control logic", "&& || ! in if", "C++ 조건문 논리 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "logical-operators"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_logical.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Logical Operators in Conditions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same nested access-control rule (`isLoggedIn && (isAdmin || securityLevel <= 2)`) and the exact same four worked-through securityLevel outcomes (1/2 granted, 3/4 denied) reappear identically from C's chapter — confirming this specific compound authorization pattern was deliberately carried over as the canonical teaching example for combining `&&`/`||` across both languages. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`&&` (AND)** — both conditions must be true. [S1]
|
||||
- **`||` (OR)** — at least one condition must be true. [S1]
|
||||
- **`!` (NOT)** — reverses a condition's truth value. [S1]
|
||||
- **Nested logical composition** — parentheses group sub-conditions that combine with another condition via `&&`, mirroring real authorization rules. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- AND: `int a = 200, b = 33, c = 500; if (a > b && c > a) { cout << "Both conditions are true"; }`. [S1]
|
||||
- OR: `if (a > b || a > c) { cout << "At least one condition is true"; }`. [S1]
|
||||
- NOT: `int a = 33; int b = 200; if (!(a > b)) { cout << "a is NOT greater than b"; }`. [S1]
|
||||
- Full access-control rule with worked-through outcomes: `bool isLoggedIn = true; bool isAdmin = false; int securityLevel = 3; if (isLoggedIn && (isAdmin || securityLevel <= 2)) { cout << "Access granted."; } else { cout << "Access denied."; }` — securityLevel 1 or 2 → granted; 3 or 4 → denied (unless isAdmin is true). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터의 접근 제어 예제와 완전히 동일함이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
로그인 여부(isLoggedIn) + (관리자이거나(isAdmin) 보안등급이 2 이하(securityLevel <= 2))를 결합한 접근 제어 규칙이 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested AND/OR logic for a real-world access-control rule (C++):
|
||||
```cpp
|
||||
bool isLoggedIn = true;
|
||||
bool isAdmin = false;
|
||||
int securityLevel = 3; // 1 = highest
|
||||
if (isLoggedIn && (isAdmin || securityLevel <= 2)) {
|
||||
cout << "Access granted.";
|
||||
} else {
|
||||
cout << "Access denied.";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions Shorthand]], [[CPP Operators Logical]], [[CPP Conditions Nested]]
|
||||
- **참조 맥락:** 조건문 내 논리 연산자 — 중첩 if(Conditions Nested) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Logical Operators in Conditions — https://www.w3schools.com/cpp/cpp_conditions_logical.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Logical Operators in Conditions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: cpp-conditions-nested
|
||||
title: "C++ Nested If"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["if inside if", "dependent conditions", "C++ 중첩 if"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "nested-if"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_nested.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Nested If]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The same short-circuit benefit from C's Nested If chapter applies unchanged — the citizenship check (`isCitizen`) is never even evaluated if `age >= 18` is false, meaning nesting still functions as a genuine short-circuit optimization in C++, not just visual grouping of related checks. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested if** — placing an `if` inside another `if`'s block, so the inner condition is only checked when the outer condition already holds. [S1]
|
||||
- **Dependent condition modeling** — naturally expresses "check B only if A holds." [S1]
|
||||
- **Depth caution** — avoid nesting too deeply, as it hurts readability; often combined with `else`/`else if`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic two-level nesting: `int x = 15; int y = 25; if (x > 10) { cout << "x is greater than 10\n"; if (y > 20) { cout << "y is also greater than 20\n"; } }`. [S1]
|
||||
- Voting + citizenship real-life example: `int age = 20; bool isCitizen = true; if (age >= 18) { cout << "Old enough to vote.\n"; if (isCitizen) { cout << "And you are a citizen, so you can vote!\n"; } else { cout << "But you must be a citizen to vote.\n"; } } else { cout << "Not old enough to vote.\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 중첩 if 및 단축 평가 특성이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
투표 가능 연령(18세 이상)을 먼저 확인하고, 그 안에서만 시민권 여부를 추가로 확인하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
An inner condition (citizenship) checked only when the outer condition (age) already holds (C++):
|
||||
```cpp
|
||||
int age = 20;
|
||||
bool isCitizen = true;
|
||||
if (age >= 18) {
|
||||
cout << "Old enough to vote.\n";
|
||||
if (isCitizen) {
|
||||
cout << "And you are a citizen, so you can vote!\n";
|
||||
} else {
|
||||
cout << "But you must be a citizen to vote.\n";
|
||||
}
|
||||
} else {
|
||||
cout << "Not old enough to vote.\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions Logical]], [[CPP Conditions RealLife]], [[C Conditions Nested]]
|
||||
- **참조 맥락:** 중첩 if — 조건문 실전 예제(Conditions RealLife) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Nested If — https://www.w3schools.com/cpp/cpp_conditions_nested.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Nested If" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-conditions-reallife
|
||||
title: "C++ If ... Else Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["real-life if else", "even or odd example", "C++ 조건문 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP If ... Else Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The five worked scenarios (door code, positive/negative/zero, voting age, nested citizenship check, even/odd via `%`) mirror C's real-life if/else chapter almost verbatim — the sole notable omission is C's temperature-banding example, meaning this chapter consolidates the same core parity-check and equality-check idioms while trimming one example from the C original. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **This chapter is a compilation** — worked real-life if/else scenarios consolidating patterns from every prior Conditions sub-chapter. [S1]
|
||||
- **Door-code check** — a single `==` equality check gating access. [S1]
|
||||
- **Positive/negative/zero classification** — a three-way `if`/`else if`/`else` chain. [S1]
|
||||
- **Even/odd via modulus** — `num % 2 == 0` is the standard parity-check idiom, same as in C. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Door code check: `int doorCode = 1337; if (doorCode == 1337) { cout << "Correct code.\nThe door is now open.\n"; } else { cout << "Wrong code.\nThe door remains closed.\n"; }`. [S1]
|
||||
- Positive/negative/zero: `int myNum = 10; if (myNum > 0) { cout << "The value is a positive number.\n"; } else if (myNum < 0) { cout << "The value is a negative number.\n"; } else { cout << "The value is 0.\n"; }`. [S1]
|
||||
- Even/odd check: `int myNum = 5; if (myNum % 2 == 0) { cout << myNum << " is even.\n"; } else { cout << myNum << " is odd.\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
도어락 코드 확인, 숫자 부호 판별, 투표 연령, 짝/홀수 판별 등이 원문에서 직접 제시되며, 각각이 조건문 섹션 전체를 종합한 실전 활용 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The standard parity-check idiom using the modulus operator (C++):
|
||||
```cpp
|
||||
int myNum = 5;
|
||||
if (myNum % 2 == 0) {
|
||||
cout << myNum << " is even.\n";
|
||||
} else {
|
||||
cout << myNum << " is odd.\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions Nested]], [[CPP Operators Arithmetic]], [[CPP Switch]]
|
||||
- **참조 맥락:** 조건문 섹션 마지막 — switch 문(Switch) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ If ... Else Examples — https://www.w3schools.com/cpp/cpp_conditions_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ If ... Else Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-conditions-shorthand
|
||||
title: "C++ Short Hand If Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["ternary operator", "nested ternary", "C++ 삼항 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "conditions", "ternary-operator"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_conditions_shorthand.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Short Hand If Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike C's equivalent chapter (which only replaces two `printf()` calls with a ternary), C++'s version goes one step further with NESTED ternaries — chaining `(time < 12) ? "Good morning." : (time < 18) ? "Good afternoon." : "Good evening.";` to handle THREE outcomes in one expression — while explicitly warning this makes code harder to read, showing C++'s string type enables a genuinely richer ternary use case (storing a computed STRING result) that C's more limited ternary (usually just printing directly) didn't showcase. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Ternary operator (`?:`)** — a shorthand if/else that RETURNS a value; syntax: `variable = (condition) ? expressionTrue : expressionFalse;`. [S1]
|
||||
- **Storing the result in a `string` variable** — `string result = (time < 18) ? "Good day." : "Good evening.";` — leverages C++'s string type directly. [S1]
|
||||
- **Using it inline inside `cout`** — `cout << ((time < 18) ? "Good day." : "Good evening.");` — no intermediate variable needed. [S1]
|
||||
- **Nested ternary** — chaining multiple `?:` expressions to handle MORE than two outcomes, at the cost of readability. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Storing the ternary result in a string: `int time = 20; string result = (time < 18) ? "Good day." : "Good evening."; cout << result;`. [S1]
|
||||
- Inline ternary directly inside cout: `cout << ((time < 18) ? "Good day." : "Good evening.");`. [S1]
|
||||
- Nested ternary handling three outcomes: `int time = 22; string message = (time < 12) ? "Good morning." : (time < 18) ? "Good afternoon." : "Good evening."; cout << message;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **중첩 삼항 연산자는 가독성 저하 경고와 함께 사용 가능**: 세 가지 이상의 결과를 하나의 삼항 표현식으로 처리할 수 있지만, 명확성을 위해 보통은 일반 if...else if...else 문을 쓰는 것이 낫다고 명시적으로 권고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 짝수/홀수 판정 결과를 삼항 연산자로 문자열에 담는 연습문제가 실전 활용의 대표 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested ternary operators handling three possible outcomes (C++):
|
||||
```cpp
|
||||
int time = 22;
|
||||
string message = (time < 12) ? "Good morning."
|
||||
: (time < 18) ? "Good afternoon."
|
||||
: "Good evening.";
|
||||
cout << message;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Conditions ElseIf]], [[CPP Conditions Logical]], [[C Conditions Short Hand]]
|
||||
- **참조 맥락:** 삼항 연산자 — 조건문 내 논리 연산자(Conditions Logical) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Short Hand If Else — https://www.w3schools.com/cpp/cpp_conditions_shorthand.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Short Hand If Else" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-constructors
|
||||
title: "C++ Constructors"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["constructor rules", "same name as class", "no return type", "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"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_constructors.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Constructors]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A constructor breaks TWO rules every other function in C++ follows — it has NO return type at all, "not even void," and its name must be IDENTICAL to the class name — meaning a constructor isn't really "a special kind of function" so much as a fundamentally different syntactic category that happens to look function-shaped, distinguished purely by the compiler recognizing the name-matches-class pattern. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Constructor** — a special method AUTOMATICALLY called when an object is created; runs with zero explicit invocation from the programmer. [S1]
|
||||
- **Four constructor rules** — same name as the class; NO return type (not even `void`); usually declared `public`; automatically called on object creation. [S1]
|
||||
- **Constructor with parameters** — sets initial attribute values at creation time (`Car(string x, string y, int z) { brand = x; ... }`), so each object starts pre-configured. [S1]
|
||||
- **Defined outside the class** — same `::` scope resolution pattern as regular methods. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic parameterless constructor: `class MyClass { public: MyClass() { cout << "Hello World!"; } }; MyClass myObj; // triggers the constructor automatically`. [S1]
|
||||
- Constructor with parameters setting initial attributes: `class Car { public: string brand; string model; int year; Car(string x, string y, int z) { brand = x; model = y; year = z; } }; Car carObj1("BMW", "X5", 1999);`. [S1]
|
||||
- Defined outside the class via `::`: `Car(string x, string y, int z); // declaration Car::Car(string x, string y, int z) { brand = x; model = y; year = z; } // definition`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **생성자는 반환 타입이 전혀 없음**: void조차 쓰지 않는다는 점과 클래스 이름과 완전히 동일해야 한다는 점이 다른 모든 함수/메서드와 근본적으로 다른 두 가지 규칙으로 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
피자 주문 비유("생성자는 소스·치즈·토핑을 미리 얹어주는 요리사")가 생성자가 객체 생성 시 자동으로 초기 설정을 마쳐준다는 개념을 직관적으로 설명하는 실전 비유로 원문에 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A constructor with parameters setting initial attribute values automatically (C++):
|
||||
```cpp
|
||||
class Car {
|
||||
public:
|
||||
string brand;
|
||||
string model;
|
||||
int year;
|
||||
Car(string x, string y, int z) { // Constructor with parameters
|
||||
brand = x;
|
||||
model = y;
|
||||
year = z;
|
||||
}
|
||||
};
|
||||
int main() {
|
||||
Car carObj1("BMW", "X5", 1999); // constructor runs automatically
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Class Methods]], [[CPP Constructors Overloading]], [[CPP Function Overloading]]
|
||||
- **참조 맥락:** 생성자 — 생성자 오버로딩(Constructors Overloading) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Constructors — https://www.w3schools.com/cpp/cpp_constructors.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Constructors" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -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).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: cpp-data-structures
|
||||
title: "C++ Data Structures and STL"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["STL", "Standard Template Library", "C++ 자료구조"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "stl", "data-structures"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_structures.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Data Structures]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C has exactly ONE built-in data structure — the array — and everything else (linked lists, stacks, queues, hash-like maps) must be hand-built from structs and raw pointers; C++'s STL instead ships vector/list/stack/queue/deque/set/map as ready-made template classes, meaning the entire "how do I build a linked list" problem that consumed a whole chapter of Topic_C's Pointers section is simply gone from the C++ mental model — replaced by "which header do I include." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **STL (Standard Template Library)** — a library of data structures + algorithms bundled with C++, used to store and manipulate data efficiently. [S1]
|
||||
- **Containers** — data structures that store data (vector, list, stack, queue, deque, set, map). [S1]
|
||||
- **Iterators** — objects used to access elements of a container without knowing its internal layout. [S1]
|
||||
- **Algorithms** — functions like `sort()` and `find()` that operate on containers through iterators. [S1]
|
||||
- **One header per container** — each container requires its own `#include` (`<vector>`, `<list>`, `<set>`, `<map>`, `<stack>`, `<queue>`), unlike arrays which need no header. [S1]
|
||||
- **Choosing a container is a design decision** — the right data structure + algorithm makes a program run faster, especially at scale; the table of 7 containers (Vector/List/Stack/Queue/Deque/Set/Map) each optimize a different access pattern. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Container comparison table: Vector (array-like, dynamic size, index access), List (sequential, add/remove both ends, no index access), Stack (LIFO, top only), Queue (FIFO, front/back only), Deque (double-ended, index access), Set (unique elements, no index), Map (key/value pairs, access by key). [S1]
|
||||
- Minimal vector usage: `vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (string car : cars) { cout << car << "\n"; }`. [S1]
|
||||
- Containers + iterators + algorithms form a triangle: a container without an algorithm to search/manipulate it is not very useful, and an algorithm needs a container to operate on. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C에는 없는 개념 층위가 통째로 추가됨**: Topic_C에는 "자료구조 챕터"가 존재하지 않았고(배열이 유일한 내장 자료구조), 연결 리스트/스택/큐는 포인터+구조체로 직접 구현하는 예제들이 Pointers 섹션에 흩어져 있었다. C++는 이를 컨테이너+반복자+알고리즘이라는 3층 구조로 라이브러리화했다는 점이 이번 챕터에서 명확히 드러남. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 문자열 vector를 만들고 for-each로 순회하는 패턴이 원문에서 STL 소개 예제로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Required headers per container, and a first vector example (C++):
|
||||
```cpp
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <queue>
|
||||
|
||||
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
for (string car : cars) {
|
||||
cout << car << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Vectors]], [[CPP List]], [[CPP Stacks]], [[CPP Queues]], [[CPP Arrays]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션의 도입 챕터 — Vectors로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Data Structures and STL — https://www.w3schools.com/cpp/cpp_data_structures.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Data Structures and STL" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-data-types
|
||||
title: "C++ Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["basic data types table", "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", "data-types"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ elevates `bool` and `string` to genuine BASIC types listed right alongside `int`/`char`/`float`/`double` — a stark contrast to C, where `bool` required a separate `<stdbool.h>` include (added only in C99) and there was no `string` type at all (just `char` arrays) — meaning C++'s type system, despite near-identical syntax to C, treats booleans and text as first-class citizens from the very first data-types lesson. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Six basic types** — `bool` (1 byte, true/false), `char` (1 byte, single character/ASCII), `int` (2 or 4 bytes, whole numbers), `float` (4 bytes, ~6-7 decimal digit precision), `double` (8 bytes, ~15 decimal digit precision), and `string` (text, covered separately). [S1]
|
||||
- **No format specifier needed for any type** — unlike C, `cout <<` prints any of these types directly without a matching `%d`/`%f`/`%c` specifier. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All six basic types declared together: `int myNum = 5; float myFloatNum = 5.99; double myDoubleNum = 9.98; char myLetter = 'D'; bool myBoolean = true; string myText = "Hello";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **bool과 string이 C++에서는 기본 타입급으로 취급됨**: C에서는 bool이 C99 이후 <stdbool.h>를 포함해야 했고 string은 아예 없었지만(char 배열만 존재), C++에서는 이 데이터 타입 챕터부터 bool과 string이 int/char/float/double과 나란히 기본 타입으로 소개된다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 6개 기본 타입을 한 번에 선언하는 예제가 이후 각 타입별 상세 챕터의 로드맵 역할을 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The six basic C++ data types declared together, with no format specifiers needed for printing:
|
||||
```cpp
|
||||
int myNum = 5; // Integer (whole number)
|
||||
float myFloatNum = 5.99; // Floating point number
|
||||
double myDoubleNum = 9.98; // Floating point number
|
||||
char myLetter = 'D'; // Character
|
||||
bool myBoolean = true; // Boolean
|
||||
string myText = "Hello"; // String
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Variables RealLife]], [[CPP Data Types Numeric]], [[C Data Types]]
|
||||
- **참조 맥락:** 데이터 타입 섹션 첫 챕터 — 숫자형 타입(Data Types Numeric) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Data Types — https://www.w3schools.com/cpp/cpp_data_types.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: cpp-data-types-bool
|
||||
title: "C++ Boolean Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bool keyword", "C++ 불리언 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "data-types", "bool"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types_bool.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Boolean Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`bool` needs no special header include in C++ — it's a native keyword usable immediately — a direct contrast to C, where the equivalent chapter required explicitly including `<stdbool.h>` (a C99 addition) before `bool` could be used at all, reinforcing the Data Types chapter's observation that C++ treats booleans as first-class from the start. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`bool`** — a native C++ keyword (no header needed); represents `true` or `false`. [S1]
|
||||
- **Underlying integer representation when printed** — `cout << boolVar;` shows `1` for true, `0` for false, same convention as C. [S1]
|
||||
- **Primary use** — conditional testing (covered in a later chapter). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaring and printing booleans: `bool isCodingFun = true; bool isFishTasty = false; cout << isCodingFun; // 1 cout << isFishTasty; // 0`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **bool 사용에 별도 헤더가 필요 없음**: C에서는 <stdbool.h>를 반드시 포함해야 bool을 쓸 수 있었지만, C++에서는 그런 요구사항이 언급되지 않아 네이티브 키워드로 즉시 사용 가능함이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 불리언 값이 조건 테스트에 주로 쓰인다는 점이 이후 조건문(Conditions) 섹션의 기초가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Boolean values printing as their underlying integer representation (C++):
|
||||
```cpp
|
||||
bool isCodingFun = true;
|
||||
bool isFishTasty = false;
|
||||
cout << isCodingFun; // Outputs 1 (true)
|
||||
cout << isFishTasty; // Outputs 0 (false)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types Numeric]], [[CPP Data Types Char]], [[C Booleans]]
|
||||
- **참조 맥락:** 불리언 타입 — 문자 타입(Data Types Char) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Boolean Data Types — https://www.w3schools.com/cpp/cpp_data_types_bool.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Boolean Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-data-types-char
|
||||
title: "C++ Character Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["char type", "ASCII values", "C++ 문자 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "data-types", "char", "ascii"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types_char.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Character Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++'s `char` chapter drops the elaborate silent-truncation warning that C's equivalent chapter emphasized (assigning multiple characters like `'Hello'` to a `char` variable and having it silently keep only the last one) — likely because C++ has a genuine `string` type as the obvious alternative for multi-character text from the very same Data Types chapter, making the C-style char/string confusion a less central pitfall to warn about. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`char`** — stores exactly one character, written in single quotes (`'B'`). [S1]
|
||||
- **ASCII value assignment** — `char` variables can be assigned numeric ASCII codes directly (no quotes) and still print as the corresponding character. [S1]
|
||||
- **No format specifier needed** — `cout << myGrade;` prints the character directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic char: `char myGrade = 'B'; cout << myGrade;`. [S1]
|
||||
- ASCII numeric assignment: `char a = 65, b = 66, c = 67; cout << a; cout << b; cout << c;` — prints A, B, C. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — ASCII 코드값(65,66,67)을 직접 char에 대입해 A/B/C를 출력하는 패턴이 C 챕터와 동일하게 문자와 숫자 표현의 관계를 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Assigning ASCII numeric codes directly to char variables (C++):
|
||||
```cpp
|
||||
char a = 65, b = 66, c = 67;
|
||||
cout << a; // A
|
||||
cout << b; // B
|
||||
cout << c; // C
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types Bool]], [[CPP Data Types String]], [[C Data Types Characters]]
|
||||
- **참조 맥락:** 문자 타입 — 문자열 타입(Data Types String) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Character Data Types — https://www.w3schools.com/cpp/cpp_data_types_char.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Character Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-data-types-numeric
|
||||
title: "C++ Numeric Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["float vs double", "scientific notation", "C++ 숫자 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "data-types", "numbers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types_numeric.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Numeric Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same precision tradeoff from C reappears unchanged — `float` holds only 6-7 decimal digits while `double` holds ~15, and the source again recommends `double` as the SAFER default for most calculations — confirming C++'s floating-point model (and its associated precision caveats) is inherited directly from C, not redesigned. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`int`** — whole numbers without decimals. [S1]
|
||||
- **`float`** — decimal numbers, ~6-7 significant digits, 4 bytes. [S1]
|
||||
- **`double`** — decimal numbers, ~15 significant digits, 8 bytes; recommended default for most calculations. [S1]
|
||||
- **Scientific notation** — `e`/`E` means "times 10 to the power of" (e.g. `35e3` = 35000), same syntax as C. [S1]
|
||||
- **No format specifier for printing** — `cout << myNum;` works identically for `int`, `float`, or `double`, unlike C's type-matched `%d`/`%f`/`%lf`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic declarations printed with plain `cout <<` (no type-specific specifier): `int myNum = 1000; cout << myNum;`, `float myNum = 5.75; cout << myNum;`, `double myNum = 19.99; cout << myNum;`. [S1]
|
||||
- Scientific notation: `float f1 = 35e3; double d1 = 12E4; cout << f1; cout << d1;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **double을 기본으로 권장하는 것도 C와 동일**: float가 메모리를 절반만 쓰지만 대부분의 계산에는 정밀도가 더 높은 double을 쓰는 것이 더 안전하다는 조언이 C 챕터와 그대로 반복됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 과학적 표기법(35e3)으로 큰 수를 짧게 표현하는 패턴이 C 챕터와 동일하게 실전 활용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Printing float/double/int values directly with cout, no format specifier needed (C++):
|
||||
```cpp
|
||||
float f1 = 35e3; // 35 * 10^3 = 35000
|
||||
double d1 = 12E4; // 12 * 10^4 = 120000
|
||||
cout << f1;
|
||||
cout << d1;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types]], [[CPP Data Types Bool]], [[C Data Types Numbers]]
|
||||
- **참조 맥락:** 숫자 타입 — 불리언 타입(Data Types Bool) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Numeric Data Types — https://www.w3schools.com/cpp/cpp_data_types_numeric.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Numeric Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: cpp-data-types-reallife
|
||||
title: "C++ Data Types Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["real-life data types", "total cost calculation", "C++ 데이터 타입 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "data-types", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Data Types Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This example prints the currency symbol by chaining a `char` directly onto a `double` in the SAME `cout` statement (`cout << total_cost << currency;`) with no separator or format specifier needed — a direct showcase of the earlier Variables chapter's insight that `<<` chaining eliminates C's type-matching requirement, applied here to mix a monetary amount and its currency symbol seamlessly. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Mixed-type arithmetic** — multiplying an `int` (`items`) by a `double` (`cost_per_item`) and storing the result in a `double` (`total_cost`). [S1]
|
||||
- **Chaining different types in one cout statement** — combining a `double` and a `char` (currency symbol) directly via `<<`, no casting or format specifier needed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full calculation and display: `int items = 50; double cost_per_item = 9.99; double total_cost = items * cost_per_item; char currency = '$'; cout << "Number of items: " << items << "\n"; cout << "Cost per item: " << cost_per_item << currency << "\n"; cout << "Total cost = " << total_cost << currency << "\n";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
수량(int)×단가(double)로 총 비용을 계산하고 통화 기호(char)를 같은 cout 문에 이어붙이는 이 예제 자체가 영수증/가격 계산 UI의 실전 활용 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chaining a double and a char (currency symbol) in the same cout statement with no casting (C++):
|
||||
```cpp
|
||||
double total_cost = 50 * 9.99;
|
||||
char currency = '$';
|
||||
cout << "Total cost = " << total_cost << currency << "\n";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types String]], [[CPP Operators]]
|
||||
- **참조 맥락:** 데이터 타입 섹션 마지막 — 연산자(Operators) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Data Types Examples — https://www.w3schools.com/cpp/cpp_data_types_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Data Types Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-data-types-string
|
||||
title: "C++ String Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["string library", "not built-in type", "C++ 문자열 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "data-types", "string"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_data_types_string.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP String Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`string` is explicitly called out as "NOT a built-in type" despite behaving like one in basic usage — it requires including the `<string>` header before it can be used at all, meaning C++'s convenient string handling (versus C's raw `char` arrays) is a LIBRARY feature layered on top of the language, not a core language primitive like `int` or `char` are. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`string`** — stores a sequence of characters (text); values surrounded by double quotes. [S1]
|
||||
- **Not a built-in type** — requires `#include <string>` before use, unlike `int`/`char`/`bool`/`float`/`double` which need no such include. [S1]
|
||||
- **"Behaves like" a built-in type** — in basic usage (declaration, assignment, printing), `string` feels indistinguishable from a native type despite technically being library-provided. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic string declaration and printing (requires the header): `#include <string> string greeting = "Hello"; cout << greeting;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **string은 내장 타입이 아님**: int/char/bool 등과 나란히 소개되지만, 실제로는 <string> 헤더를 포함해야 사용 가능한 라이브러리 제공 타입이라는 점이 명시적으로 구분됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — <string> 헤더 포함이 문자열을 다루는 모든 C++ 프로그램의 실전 필수 전제 조건이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Using the string type, which requires including the <string> header (C++):
|
||||
```cpp
|
||||
#include <string>
|
||||
string greeting = "Hello";
|
||||
cout << greeting;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types Char]], [[CPP Data Types RealLife]], [[CPP Strings]]
|
||||
- **참조 맥락:** 문자열 타입 — 데이터 타입 실전 예제(Data Types RealLife) 챕터로 이어짐, 문자열(Strings) 섹션과 직접 연결.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ String Data Types — https://www.w3schools.com/cpp/cpp_data_types_string.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ String Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: cpp-date
|
||||
title: "C++ Date and Time"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["ctime library", "mktime", "strftime", "clock() timing", "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", "date-time", "ctime"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_date.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Date and Time]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`mktime()` isn't just for CONVERTING a manually-built date into a timestamp — the source shows it also SELF-CORRECTS invalid dates (setting day-of-month to 32 and calling `mktime()` normalizes it into a valid date, unlike `asctime()` which just displays "32" verbatim without correcting it) and FILLS IN derived fields like the weekday (`tm_wday`) automatically, meaning `mktime()` does double duty as both a converter and a date-validator/completer that the more display-focused functions (`ctime()`, `asctime()`) don't provide. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Two date representations** — `time_t` (a single-number timestamp, easy for calculation) vs. `struct tm` (a structure with separate `tm_sec`/`tm_min`/`tm_hour`/`tm_mday`/`tm_mon`/`tm_year`/`tm_wday`/`tm_yday` fields, easier for humans to specify). [S1]
|
||||
- **Offset conventions to remember** — hours are 24-hour format; months are 0-11 (December = 11, not 12); years are relative to 1900 (2024 = 124). [S1]
|
||||
- **`mktime()`** — converts a `struct tm` INTO a `time_t` timestamp; ALSO fills in `tm_wday`/`tm_yday` automatically and CORRECTS invalid date values (e.g. day 32 gets normalized). [S1]
|
||||
- **`localtime()` / `gmtime()`** — convert a timestamp INTO a `struct tm`, in local time zone or GMT respectively; return a POINTER, so dereference to get a stable copy if needed. [S1]
|
||||
- **`ctime()` / `asctime()`** — display a date as a fixed-format string (from a timestamp or a `struct tm` respectively); `asctime()` does NOT correct invalid dates, unlike `mktime()`. [S1]
|
||||
- **`strftime()`** — formats a date into a CUSTOM string layout using format specifiers (`%B`, `%H`, `%Y`, etc.), writing into a caller-provided `char` buffer. [S1]
|
||||
- **`difftime()`** — measures SECONDS between two timestamps, for date-level time differences. [S1]
|
||||
- **`clock()`** — measures short program-execution intervals in "clocks" (via `clock_t`), converted to seconds by dividing by `CLOCKS_PER_SEC`; more precise than `difftime()` for measuring runtime performance. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `mktime()` correcting an invalid date before display: `struct tm datetime; datetime.tm_mday = 32; /* other fields set */ mktime(&datetime); cout << asctime(&datetime); // normalized to a valid date`. [S1]
|
||||
- Formatting a date multiple ways with `strftime()`: `strftime(output, 50, "%B %e, %Y", &datetime); // "December 17, 2023" strftime(output, 50, "%I:%M:%S %p", &datetime); // "12:30:01 PM"`. [S1]
|
||||
- Measuring execution time precisely with `clock()`: `clock_t before = clock(); /* work */ clock_t duration = clock() - before; cout << (float)duration / CLOCKS_PER_SEC << " seconds";` — casting to `float` BEFORE dividing avoids integer-division truncation. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **mktime()는 변환뿐 아니라 날짜 보정과 요일 계산까지 수행**: 32일처럼 잘못된 날짜 값을 정규화하고 tm_wday/tm_yday를 자동으로 채워준다는 점이 단순 표시 함수인 asctime()/ctime()과의 핵심 차이로 확인됨. [S1]
|
||||
- **clock() 나눗셈 시 정수 나눗셈 주의**: CLOCKS_PER_SEC로 나누기 전에 float/double로 캐스팅하지 않으면 정수 나눗셈으로 소수점이 잘려나간다는 점이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
100,000번 반복 루프의 실행 시간을 clock()으로 측정하는 예제가 프로그램 성능 측정의 실전 활용 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Measuring program execution time precisely with clock(), casting before dividing (C++):
|
||||
```cpp
|
||||
clock_t before = clock();
|
||||
int k = 0;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
k += i;
|
||||
}
|
||||
clock_t duration = clock() - before;
|
||||
cout << "Duration: " << (float)duration / CLOCKS_PER_SEC << " seconds";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP User Input]], [[CPP Pointers Dereference]], [[CPP Errors]]
|
||||
- **참조 맥락:** 사용자 입력 및 날짜 섹션 마지막 — 에러 및 디버깅(Errors & Debugging) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Date and Time — https://www.w3schools.com/cpp/cpp_date.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Date and Time" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-debugging
|
||||
title: "C++ Debugging"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["print debugging", "breakpoints", "debugging vs exception handling", "C++ 디버깅"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "debugging"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_debugging.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Debugging]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The closing distinction ("debugging is about finding/fixing errors DURING DEVELOPMENT; exception handling is dealing with errors WHILE THE PROGRAM RUNS") is IDENTICAL to C's Debugging chapter's conclusion — except in C++, "exception handling" now refers to a REAL language feature (`try`/`catch`) rather than C's manual NULL-checking workarounds, meaning the conceptual division between the two development-vs-runtime phases stays the same across languages, but the runtime-side tool it points to is genuinely more powerful in C++. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Print debugging** — using `cout` to trace how far execution gets before something goes wrong. [S1]
|
||||
- **Checking variable values** — printing intermediate results to catch LOGIC errors, not just crashes. [S1]
|
||||
- **IDE debuggers** — breakpoints, line-by-line stepping, variable-watching; recommended as a step up once comfortable with print debugging. [S1]
|
||||
- **Reading error messages literally** — the compiler states exactly what's wrong and where. [S1]
|
||||
- **Debugging vs. exception handling** — debugging finds/fixes mistakes DURING DEVELOPMENT; exception handling responds to problems WHILE THE PROGRAM RUNS — the same C-established distinction, but now backed by C++'s real try/catch mechanism instead of C's manual workarounds. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Print debugging locating a crash point: `cout << "Before division\n"; int z = x / y; // crashes cout << "After division\n"; // never runs`. [S1]
|
||||
- Logic-error detection via variable printing: `int result = x - y; cout << "Result: " << result << "\n"; // expected 15, got 5 — wrong operator used`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **디버깅과 예외 처리의 구분은 C와 동일하지만 예외 처리 자체는 더 강력함**: 개발 중 디버깅 vs 실행 중 에러 대응이라는 구분은 C와 같지만, C++에서는 그 "실행 중 대응" 수단이 진짜 언어 차원의 try/catch라는 점이 C의 수동적 우회책과 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — cout으로 코드 실행 지점을 추적해 크래시 위치를 찾는 print debugging이 실전에서 가장 먼저 시도하는 디버깅 기법으로 권장됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Print debugging to locate exactly where a program crashes (C++):
|
||||
```cpp
|
||||
int x = 10;
|
||||
int y = 0;
|
||||
cout << "Before division\n"; // Debug output
|
||||
int z = x / y; // Crashes!
|
||||
cout << "After division\n"; // Never runs — crash located
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Input Validation]], [[CPP Exceptions]], [[CPP Files]]
|
||||
- **참조 맥락:** 에러 및 디버깅 섹션 마지막 — 파일 입출력(Files) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Debugging — https://www.w3schools.com/cpp/cpp_debugging.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Debugging" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-deque
|
||||
title: "C++ Deque"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::deque", "double-ended queue C++", "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", "stl", "deque"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_deque.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Deque]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`deque` is what queue "should have been" if index access mattered — it takes queue's both-ends-conceptual-flexibility one step further by ALSO allowing `[]`/`.at()` indexing like vector, meaning deque is effectively "vector + list's both-ends growth combined," and its existence exposes that the earlier stack/queue restrictions (no brace-init, single/dual access points) were deliberate design trade-offs rather than technical limitations of the "add/remove from ends" idea itself. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Deque = double-ended queue** — unlike a plain queue (front removal, back insertion only), a deque allows adding AND removing from BOTH ends. [S1]
|
||||
- **Index access restored** — unlike stack/queue/list, a deque supports `[]` and `.at()` just like vector, combining both-ends flexibility with random access. [S1]
|
||||
- **Brace-initialization allowed** — unlike stack/queue, `deque<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};` works directly, matching vector/list syntax. [S1]
|
||||
- **`.push_front()` / `.push_back()`, `.pop_front()` / `.pop_back()`** — identical method names to `list`, giving deque list's symmetric growth PLUS vector's indexing. [S1]
|
||||
- **`.front()` / `.back()`, `.size()` / `.empty()`** — same as every other sequence container covered so far. [S1]
|
||||
- **Looping** — both indexed `for` + `.size()` and for-each work, exactly like vector (unlike list, which only supports for-each). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Access: `cars[0]`, `cars.front()`, `cars.back()`, `cars.at(1)` — same safety trade-off as vector (`.at()` throws on out-of-range, `[]` does not). [S1]
|
||||
- Add/remove at both ends: `cars.push_front("Tesla"); cars.push_back("VW"); cars.pop_front(); cars.pop_back();`. [S1]
|
||||
- Both loop styles supported: indexed `for (int i = 0; i < cars.size(); i++)` AND for-each `for (string car : cars)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **stack/queue의 제약이 deque에는 적용되지 않음**: stack과 queue는 선언 시 중괄호 초기화가 불가능했지만, deque는 vector/list와 동일하게 `= {...}`로 즉시 초기화가 가능하다는 점이 이번 챕터에서 확인됨 — 앞서의 제약이 "양 끝 삽입/삭제 컨테이너의 본질"이 아니라 설계 선택이었음을 보여줌. [S1]
|
||||
- **인덱스 접근과 양쪽 끝 성장이 동시에 가능해짐**: list는 양쪽 끝 성장은 가능했지만 인덱스 접근이 불가능했고, queue/stack은 인덱스 접근도 양쪽 끝 임의 접근도 안 됐지만, deque는 이 둘을 모두 갖춘 컨테이너로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 이름 deque에 인덱스 접근, 양 끝 push/pop, 순회를 모두 적용하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Deque combines vector's indexing with list's both-ends growth (C++):
|
||||
```cpp
|
||||
#include <deque>
|
||||
deque<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
|
||||
cout << cars[0]; // indexed access, like vector
|
||||
cars.push_front("Tesla"); // both-ends growth, like list
|
||||
cars.push_back("VW");
|
||||
cars.pop_front();
|
||||
cars.pop_back();
|
||||
|
||||
for (int i = 0; i < cars.size(); i++) { // indexed loop works too
|
||||
cout << cars[i] << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Queues]], [[CPP Vectors]], [[CPP List]], [[CPP Sets]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Sets 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Deque — https://www.w3schools.com/cpp/cpp_deque.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Deque" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-do-while-loop
|
||||
title: "C++ Do/While Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["do while", "at-least-once loop", "C++ do-while 반복문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "do-while"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_do_while_loop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Do/While Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter explicitly flags something C's equivalent never called out as its own note: "the semicolon after the while condition is required!" — a small but real syntax trap, since `do {...} while(condition)` LOOKS like it should end like a regular `while` loop (no trailing semicolon), but the `do/while` FORM specifically requires one, unlike every other loop and conditional block in C++. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`do { ... } while (condition);`** — executes the block ONCE unconditionally, then checks the condition. [S1]
|
||||
- **Required trailing semicolon** — unlike `while(...) {...}` or `if(...) {...}`, the `do/while` form's closing `while(condition)` MUST end with a semicolon. [S1]
|
||||
- **Guaranteed first execution** — runs at least once even if the condition is false immediately. [S1]
|
||||
- **Input-validation pattern** — repeatedly prompting via `cin >>` until the loop condition fails. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Standard case with the required semicolon: `int i = 0; do { cout << i << "\n"; i++; } while (i < 5);`. [S1]
|
||||
- Guaranteed-once case (condition false at start): `int i = 10; do { cout << "i is " << i << "\n"; i++; } while (i < 5);` — still prints once. [S1]
|
||||
- Practical input-validation loop: `int number; do { cout << "Enter a positive number: "; cin >> number; } while (number > 0);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **do/while 뒤에는 반드시 세미콜론 필요**: while(condition) 뒤에 세미콜론을 빠뜨리기 쉬운 문법적 함정이 있다는 점이 C 챕터에는 없던 별도 주의사항으로 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
사용자로부터 양수를 입력받되 0이나 음수가 입력될 때까지 반복해서 물어보는 입력 검증 루프가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The required trailing semicolon after a do/while loop's condition (C++):
|
||||
```cpp
|
||||
int i = 0;
|
||||
do {
|
||||
cout << i << "\n";
|
||||
i++;
|
||||
}
|
||||
while (i < 5); // semicolon required here
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP While Loop RealLife]], [[CPP For Loop]], [[C Do While Loop]]
|
||||
- **참조 맥락:** while 루프의 변형 — for 루프(For Loop) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Do/While Loop — https://www.w3schools.com/cpp/cpp_do_while_loop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Do/While Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: cpp-encapsulation
|
||||
title: "C++ Encapsulation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["getter setter", "private attribute access", "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", "encapsulation"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_encapsulation.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Encapsulation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Encapsulation is the concrete APPLICATION of the previous chapter's abstract advice — "declare attributes private as often as you can" becomes actionable once you pair each `private` attribute with a `public` getter/setter method, meaning encapsulation isn't a separate new technique so much as the standard PATTERN for actually using `private` without making the data completely unreachable. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Encapsulation** — hiding "sensitive" data by declaring class attributes `private`, then providing `public` GET and SET methods for controlled access. [S1]
|
||||
- **Setter method** — a public method that ASSIGNS a value to a private attribute (`void setSalary(int s) { salary = s; }`). [S1]
|
||||
- **Getter method** — a public method that RETURNS a private attribute's value (`int getSalary() { return salary; }`). [S1]
|
||||
- **Real-life analogy** — an employee's salary is private (they can't change it directly); only the manager (a trusted method) can update or share it. [S1]
|
||||
- **Why encapsulate** — better control of data (change one part without affecting others), increased data security. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A private attribute accessed exclusively through a getter/setter pair: `class Employee { private: int salary; public: void setSalary(int s) { salary = s; } int getSalary() { return salary; } }; Employee myObj; myObj.setSalary(50000); cout << myObj.getSalary();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
직원의 급여(salary)를 private으로 숨기고 setSalary()/getSalary()로만 접근하도록 하는 Employee 클래스 예제가 캡슐화의 대표 실전 활용 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A private attribute accessed only through public getter/setter methods (C++):
|
||||
```cpp
|
||||
class Employee {
|
||||
private:
|
||||
int salary; // hidden
|
||||
public:
|
||||
void setSalary(int s) { salary = s; }
|
||||
int getSalary() { return salary; }
|
||||
};
|
||||
int main() {
|
||||
Employee myObj;
|
||||
myObj.setSalary(50000);
|
||||
cout << myObj.getSalary();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Access Specifiers]], [[CPP Inheritance]]
|
||||
- **참조 맥락:** 접근 지정자 및 캡슐화 섹션 마지막 — 상속(Inheritance) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Encapsulation — https://www.w3schools.com/cpp/cpp_encapsulation.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Encapsulation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-enum
|
||||
title: "C++ Enumeration (enum)"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["enum keyword", "named constants", "C++ 열거형"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "enums"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_enum.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Enumeration (enum)]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter is essentially IDENTICAL to C's enum chapter in every detail — default zero-based numbering, forward-cascading custom values, and enum-in-switch usage all reappear with the exact same `Level`/`LOW`/`MEDIUM`/`HIGH` example — the only visible change is `cout <<` replacing `printf("%d", ...)`, confirming C++ inherited its enum semantics from C completely unmodified (unlike structs, where C++ added meaningful new behavior). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`enum`** — a type representing a group of named, unchangeable constants. [S1]
|
||||
- **Default numbering** — first item is 0, second is 1, etc. [S1]
|
||||
- **Forward-cascading custom values** — setting one item's value shifts all subsequent unlabeled items to continue counting up from it. [S1]
|
||||
- **Enum as an int under the hood** — printing an enum variable with `cout <<` shows its underlying integer value, enabling direct use in `switch` statements. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Default numbering: `enum Level { LOW, MEDIUM, HIGH }; enum Level myVar = MEDIUM; cout << myVar; // 1`. [S1]
|
||||
- Fully custom values: `enum Level { LOW = 25, MEDIUM = 50, HIGH = 75 };`. [S1]
|
||||
- Cascading from one custom value: `enum Level { LOW = 5, MEDIUM, HIGH };` — MEDIUM becomes 6, HIGH becomes 7. [S1]
|
||||
- Enum used in a switch: `enum Level myVar = MEDIUM; switch (myVar) { case 1: ... case 2: ... case 3: ... }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 열거형 동작(기본 번호 매기기, 연쇄적 값 갱신, switch 연동)이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 요일이나 월과 같이 절대 변하지 않는 값 집합에 enum을 사용하는 것이 실전 활용의 대표 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Setting one enum value causes subsequent items to cascade forward from it (C++):
|
||||
```cpp
|
||||
enum Level {
|
||||
LOW = 5,
|
||||
MEDIUM, // Now 6
|
||||
HIGH // Now 7
|
||||
};
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Structs]], [[CPP Switch]], [[CPP References]], [[C Enums]]
|
||||
- **참조 맥락:** 구조체 및 열거형 섹션 마지막 — 참조·포인터·메모리(References, Pointers & Memory) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Enumeration (enum) — https://www.w3schools.com/cpp/cpp_enum.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Enumeration (enum)" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-errors
|
||||
title: "C++ Errors"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["compile-time vs runtime errors", "dangling pointer", "C++ 에러"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "errors"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_errors.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Errors]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The three runtime error examples (divide-by-zero, out-of-bounds array access, using DELETED memory via a dangling pointer) all share the same trait as C's equivalent chapter — none are caught at compile time, all three compile cleanly and only misbehave when actually executed — but C++'s third example specifically involves `new`/`delete` (`int* ptr = new int(10); delete ptr; cout << *ptr;`), a "dangling pointer" scenario that has no direct C equivalent since C's version used plain `malloc`/`free`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Compile-time errors** — prevent compilation entirely; e.g. missing semicolon, undeclared variable, type mismatch (`invalid conversion from 'const char*' to 'int'`). [S1]
|
||||
- **Runtime errors** — the program compiles but crashes/misbehaves when RUN; e.g. division by zero, out-of-bounds array access, dangling pointer (reading memory after `delete`). [S1]
|
||||
- **Dangling pointer** — a pointer that still holds an address after that memory was `delete`d; dereferencing it (`*ptr`) is invalid, C++-specific terminology tied to `new`/`delete`. [S1]
|
||||
- **Good habits** — initialize variables, use meaningful names, keep indentation clean, keep functions short/focused, verify loop/condition behavior, read error messages carefully. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Type mismatch error message (more specific than C's generic phrasing): `int x = "Hello"; // error: invalid conversion from 'const char*' to 'int'`. [S1]
|
||||
- Dangling pointer, a C++-specific runtime error: `int* ptr = new int(10); delete ptr; cout << *ptr; // invalid — dereferencing freed memory`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **댕글링 포인터는 new/delete와 결합된 C++ 특유의 표현**: C의 use-after-free 예제가 malloc/free 기반이었다면, C++에서는 new/delete와 결합된 "댕글링 포인터"라는 구체적 용어로 동일한 문제가 재확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 컴파일 타임 에러 3종과 런타임 에러 3종을 나란히 대비시킨 것이 두 에러 범주의 근본적 차이를 이해하는 실전 학습 자료로 활용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Using memory after it's been deleted — a dangling pointer, compiles fine but is invalid at runtime (C++):
|
||||
```cpp
|
||||
int* ptr = new int(10);
|
||||
delete ptr;
|
||||
cout << *ptr; // invalid — dangling pointer
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Date]], [[CPP Memory Management New]], [[CPP Exceptions]]
|
||||
- **참조 맥락:** 에러 섹션 첫 챕터 — 예외 처리(Exceptions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Errors — https://www.w3schools.com/cpp/cpp_errors.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Errors" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: cpp-exceptions
|
||||
title: "C++ Exceptions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["try catch throw", "exception handling", "catch all (...)", "C++ 예외 처리"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "exceptions", "try-catch"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_exceptions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Exceptions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ has the try/catch/throw mechanism that C's Error Handling chapter EXPLICITLY said C lacks entirely — meaning this is the single biggest error-handling divergence between the two languages: where C forced programmers into manual NULL-checking, `errno`, and `perror()` workarounds, C++ provides genuine LANGUAGE-LEVEL exception handling that can catch ANY thrown value, even without knowing its type in advance (via the `catch (...)` catch-all syntax). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Exception** — C++'s technical term for the error that occurs when something goes wrong; "C++ will THROW an exception." [S1]
|
||||
- **`try`** — defines the code block to test for possible errors. [S1]
|
||||
- **`throw`** — triggers an exception, optionally carrying a VALUE (of any type, e.g. `throw 505;` or `throw age;`). [S1]
|
||||
- **`catch (type param)`** — handles the exception; its parameter TYPE must match what was thrown (e.g. `catch (int errorCode)` for an `int`-typed throw). [S1]
|
||||
- **`catch (...)`** — the "three dots" catch-all syntax; handles ANY exception type when you don't know (or don't need to distinguish) the thrown type in advance. [S1]
|
||||
- **No error = catch block skipped** — if the `try` block never throws, the `catch` block simply doesn't run. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic throw/catch with a custom error code: `try { throw 505; } catch (int errorCode) { cout << "Error occurred: " << errorCode; }`. [S1]
|
||||
- Real-life age-check example throwing the actual failing value: `try { int age = 15; if (age >= 18) { cout << "Access granted."; } else { throw (age); } } catch (int myNum) { cout << "Access denied. Age is: " << myNum; }`. [S1]
|
||||
- Catch-all syntax when the thrown type is unknown: `try { ... throw 505; } catch (...) { cout << "Access denied."; }` — handles the exception without needing to declare its type. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C에는 없던 진짜 예외 처리 메커니즘**: C의 Error Handling 챕터가 "C에는 try/catch가 없다"고 명시했던 것과 정반대로, C++는 try/throw/catch라는 언어 차원의 예외 처리를 제공하며, catch(...)로 타입을 몰라도 모든 예외를 잡을 수 있다는 점까지 C에는 없던 기능으로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
사용자의 나이가 18세 미만이면 예외를 던지고 접근을 거부하는 age-check 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Catching any exception type without needing to know it in advance (C++):
|
||||
```cpp
|
||||
try {
|
||||
int age = 15;
|
||||
if (age >= 18) {
|
||||
cout << "Access granted - you are old enough.";
|
||||
} else {
|
||||
throw 505;
|
||||
}
|
||||
}
|
||||
catch (...) { // catches any exception type
|
||||
cout << "Access denied - You must be at least 18 years old.\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Errors]], [[CPP Input Validation]], [[C Error Handling]]
|
||||
- **참조 맥락:** 예외 처리 — 입력 검증(Input Validation) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Exceptions — https://www.w3schools.com/cpp/cpp_exceptions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Exceptions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: cpp-files
|
||||
title: "C++ Files"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fstream library", "ofstream ifstream", "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", "files", "fstream"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_files.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Files]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ replaces C's SINGLE `FILE*` type + mode-string (`"r"`/`"w"`/`"a"`) approach with THREE distinct CLASSES — `ofstream` (write-only), `ifstream` (read-only), `fstream` (both) — and reuses the SAME `<<`/`getline()` idioms already learned for `cout`/`cin`, meaning file I/O in C++ isn't a separate API to learn but the SAME stream-object pattern applied to files instead of the console. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`<fstream>`** — the header required for file operations, used ALONGSIDE `<iostream>`. [S1]
|
||||
- **`ofstream`** — creates and writes to files. [S1]
|
||||
- **`ifstream`** — reads from files. [S1]
|
||||
- **`fstream`** — combines both: create, read, AND write. [S1]
|
||||
- **Writing via `<<`** — the SAME insertion operator used for `cout` writes directly to a file object (`MyFile << "text";`). [S1]
|
||||
- **Reading via `getline()`** — the SAME function used for `cin` input reads a file line by line inside a `while` loop, which naturally stops when there are no more lines. [S1]
|
||||
- **`.close()`** — closing the file is good practice, cleaning up unnecessary memory. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Creating and writing a file: `ofstream MyFile("filename.txt"); MyFile << "Files can be tricky, but it is fun enough!"; MyFile.close();`. [S1]
|
||||
- Reading a file line by line: `string myText; ifstream MyReadFile("filename.txt"); while (getline(MyReadFile, myText)) { cout << myText; } MyReadFile.close();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **파일 입출력이 콘솔 입출력과 동일한 문법을 재사용함**: C가 fopen()에 모드 문자열("r"/"w"/"a")을 넘기는 단일 방식이었다면, C++는 ofstream/ifstream/fstream 세 클래스로 나누되 cout의 <<와 cin의 getline()을 그대로 파일에도 재사용한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — getline()을 while 루프와 결합해 파일을 한 줄씩 읽는 패턴이 파일 전체를 순회하는 실전 표준 방식이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reading a file line by line using getline() inside a while loop (C++):
|
||||
```cpp
|
||||
#include <fstream>
|
||||
string myText;
|
||||
ifstream MyReadFile("filename.txt");
|
||||
while (getline(MyReadFile, myText)) {
|
||||
cout << myText;
|
||||
}
|
||||
MyReadFile.close();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Debugging]], [[CPP User Input]], [[CPP Data Structures]], [[C Files]]
|
||||
- **참조 맥락:** 파일 섹션 유일 챕터이자 마지막 — 데이터 구조(STL, Data Structures) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Files — https://www.w3schools.com/cpp/cpp_files.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Files" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-for-loop
|
||||
title: "C++ For Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["for statement", "three-statement loop", "C++ for 반복문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "for-loop"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_for_loop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP For Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++'s `for` loop declares its counter INLINE inside the loop header (`for (int i = 0; i < 5; i++)`) rather than declaring `int i;` separately beforehand — a syntax choice the source demonstrates consistently across every example, meaning `i`'s SCOPE is confined to the loop itself in idiomatic C++ usage, unlike C's tutorial style which more often declared the counter as a separate statement before the loop. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`for (statement1; statement2; statement3) { ... }`** — statement1 runs once before the loop; statement2 is the continuation condition; statement3 runs after each iteration. [S1]
|
||||
- **Inline counter declaration** — `for (int i = 0; ...)` scopes `i` to the loop itself, the idiomatic C++ style shown throughout. [S1]
|
||||
- **Fixed-count use case** — the recommended tool when the number of iterations is known ahead of time. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic counting with an inline-declared counter: `for (int i = 0; i < 5; i++) { cout << i << "\n"; }`. [S1]
|
||||
- Accumulating a sum: `int sum = 0; for (int i = 1; i <= 5; i++) { sum = sum + i; } cout << "Sum is " << sum;`. [S1]
|
||||
- Countdown via decrement: `for (int i = 5; i > 0; i--) { cout << i << "\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **루프 카운터를 for 헤더 안에서 바로 선언**: C 챕터의 예제들은 int i;를 루프 밖에서 별도로 선언하는 경우가 있었지만, C++ 예제는 일관되게 for (int i = 0; ...) 형태로 헤더 안에서 바로 선언해 i의 스코프를 루프에 국한시킨다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
1부터 5까지의 합을 for 루프로 누적 계산하는 예제(sum = sum + i)가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
An inline-declared loop counter scoped to the for loop itself (C++):
|
||||
```cpp
|
||||
int sum = 0;
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
sum = sum + i;
|
||||
}
|
||||
cout << "Sum is " << sum;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Do While Loop]], [[CPP For Loop Foreach]], [[C For Loop]]
|
||||
- **참조 맥락:** for 루프 — foreach 루프(For Loop Foreach) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ For Loop — https://www.w3schools.com/cpp/cpp_for_loop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ For Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: cpp-for-loop-foreach
|
||||
title: "C++ The foreach Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["range-based for loop", "for-each", "C++ foreach 루프"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "foreach", "range-based-for"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_for_loop_foreach.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP The foreach Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This is a genuinely NEW construct that C never had at all — the range-based `for (type var : collection)` loop, introduced only in C++11 (2011), eliminates BOTH the manual index variable AND the manual bounds-check entirely, meaning C++ programmers get a loop style C users had no equivalent for, and the exact same syntax works interchangeably on an array of numbers or the characters of a string. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`for (type variableName : collectionName) { ... }`** — the range-based ("for-each") loop; iterates every element without an index variable or manual size tracking. [S1]
|
||||
- **Works on arrays** — `for (int num : myNumbers)` visits each element directly. [S1]
|
||||
- **Works on strings too** — `for (char c : word)` visits each character. [S1]
|
||||
- **C++11 introduction** — this loop form did not exist before the 2011 standard. [S1]
|
||||
- **No index or bounds-checking needed** — unlike a traditional `for` loop with `i < length`, the range-based form has no risk of an off-by-one error since it handles iteration internally. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Looping through an array: `int myNumbers[5] = {10, 20, 30, 40, 50}; for (int num : myNumbers) { cout << num << "\n"; }`. [S1]
|
||||
- Looping through a string's characters: `string word = "Hello"; for (char c : word) { cout << c << "\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C에는 없던 C++ 고유 반복문**: 인덱스 변수나 수동 경계 확인 없이 배열/문자열의 모든 원소를 순회하는 range-based for 루프는 C++11(2011)에 새로 도입된 개념으로, C 튜토리얼에는 대응 챕터가 전혀 없었다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 배열과 문자열 모두에 동일한 for-each 문법을 적용할 수 있다는 점이 실전 코드 순회 작업의 간결함을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The range-based for loop working identically on an array and a string (C++11+):
|
||||
```cpp
|
||||
int myNumbers[5] = {10, 20, 30, 40, 50};
|
||||
for (int num : myNumbers) {
|
||||
cout << num << "\n";
|
||||
}
|
||||
|
||||
string word = "Hello";
|
||||
for (char c : word) {
|
||||
cout << c << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP For Loop]], [[CPP For Loop Nested]], [[CPP Arrays]]
|
||||
- **참조 맥락:** foreach 루프 — 중첩 for 루프(For Loop Nested) 챕터로 이어짐, 배열(Arrays) 섹션과 직접 연결.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ The foreach Loop — https://www.w3schools.com/cpp/cpp_for_loop_foreach.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ The foreach Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: cpp-for-loop-nested
|
||||
title: "C++ Nested Loops"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["inner outer loop", "multiplication table", "C++ 중첩 반복문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "nested-loops"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_for_loop_nested.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Nested Loops]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The identical multiplicative execution-count annotation from C's Nested Loops chapter reappears unchanged (outer runs 2 times, inner runs "6 times (2 * 3)," not additive 5) — reconfirming that nested-loop cost scales multiplicatively in C++ exactly as it did in C, which is why nested loops remain the natural fit for 2D structures like tables and matrices in both languages. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested loop** — a loop placed entirely inside another loop's body; the inner loop runs to completion once for EVERY iteration of the outer loop. [S1]
|
||||
- **Multiplicative execution count** — total inner-body executions = (outer iterations) × (inner iterations). [S1]
|
||||
- **Natural fit for 2D data** — tables, matrices, multi-dimensional structures. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic nesting with explicit iteration-count annotation: `for (int i = 1; i <= 2; ++i) { cout << "Outer: " << i << "\n"; for (int j = 1; j <= 3; ++j) { cout << " Inner: " << j << "\n"; } }` — outer runs 2 times, inner runs 6 times total (2×3). [S1]
|
||||
- Multiplication table via nested loops: `for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3; j++) { cout << i * j << " "; } cout << "\n"; }` — produces `1 2 3 / 2 4 6 / 3 6 9`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 곱셈 관계 및 예제가 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
3x3 구구단표를 중첩 for 루프로 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A multiplication table built from two nested for loops (C++):
|
||||
```cpp
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
for (int j = 1; j <= 3; j++) {
|
||||
cout << i * j << " ";
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
// 1 2 3
|
||||
// 2 4 6
|
||||
// 3 6 9
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP For Loop Foreach]], [[CPP For Loop RealLife]], [[C For Loop Nested]]
|
||||
- **참조 맥락:** 중첩 for 루프 — for 루프 실전 예제(For Loop RealLife) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Nested Loops — https://www.w3schools.com/cpp/cpp_for_loop_nested.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Nested Loops" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-for-loop-reallife
|
||||
title: "C++ For Loop Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["powers of 2", "multiplication table generator", "C++ for 루프 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "loops", "for-loop", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_for_loop_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP For Loop Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The identical multiplicative-stepping example from C (`for (int i = 2; i <= 512; i *= 2)`) confirms C++'s `for` loop third-expression slot accepts ANY expression that changes the loop variable — not just `++`/`+=` — meaning the "increment expression" is really an arbitrary per-iteration mutation, a property inherited unchanged from C's for-loop semantics. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Additive stepping by an arbitrary amount** — `i += 10` steps by tens. [S1]
|
||||
- **Multiplicative stepping** — `i *= 2` doubles the value each iteration, producing powers of 2. [S1]
|
||||
- **Parameterized multiplication table** — using a variable (`number`) instead of a hardcoded value generates any number's table. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Counting by tens: `for (int i = 0; i <= 100; i += 10) { cout << i << "\n"; }`. [S1]
|
||||
- Powers of 2 via multiplicative stepping: `for (int i = 2; i <= 512; i *= 2) { cout << i << "\n"; }` — 2, 4, 8, ..., 512. [S1]
|
||||
- Parameterized multiplication table: `int number = 2; for (i = 1; i <= 10; i++) { cout << number << " x " << i << " = " << number * i << "\n"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 곱셈 증가식이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
2의 거듭제곱을 512까지 출력하는 예제와, 임의의 숫자에 대한 구구단표를 생성하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Multiplicative stepping in a for loop to generate powers of 2 (C++):
|
||||
```cpp
|
||||
for (int i = 2; i <= 512; i *= 2) {
|
||||
cout << i << "\n";
|
||||
}
|
||||
// 2, 4, 8, 16, 32, 64, 128, 256, 512
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP For Loop Nested]], [[CPP Break]], [[C For Loop RealLife]]
|
||||
- **참조 맥락:** for 루프 실전 예제 — break/continue 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ For Loop Examples — https://www.w3schools.com/cpp/cpp_for_loop_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ For Loop Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: cpp-friend-function
|
||||
title: "C++ The Friend Keyword"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["friend function", "bypass encapsulation", "C++ friend 키워드"]
|
||||
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", "friend", "encapsulation"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_friend_function.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP The Friend Keyword]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A `friend` function is deliberately EXEMPT from the entire Encapsulation chapter's rule — it's NOT a member of the class at all, yet it can read `private` data directly with no getter method required, meaning `friend` is a language-level ESCAPE HATCH from encapsulation, granted explicitly and individually per-function rather than a general loophole, since each `friend` declaration must name exactly which external function gets the privilege. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Friend function** — a function that is NOT a member of the class, but is explicitly GRANTED access to the class's `private` members. [S1]
|
||||
- **Declared inside, defined outside** — the friend function's declaration lives INSIDE the class (marked with `friend`), but its actual body is written OUTSIDE the class like a normal function. [S1]
|
||||
- **Bypasses the getter/setter requirement** — unlike ordinary external code (which must use public getters/setters per the Encapsulation chapter), a friend function reads `private` members directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A friend function accessing a private attribute directly: `class Employee { private: int salary; public: Employee(int s) { salary = s; } friend void displaySalary(Employee emp); }; void displaySalary(Employee emp) { cout << "Salary: " << emp.salary; } Employee myEmp(50000); displaySalary(myEmp);` — `displaySalary` isn't a class member but reads `emp.salary` directly. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **friend는 캡슐화 규칙의 예외**: 일반적으로 private 멤버는 public 게터/세터로만 접근해야 하지만, friend로 선언된 함수는 클래스의 멤버가 아님에도 private 데이터를 직접 읽을 수 있다는 점에서 캡슐화 원칙의 명시적 예외임이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Employee의 private 급여(salary)를 friend 함수 displaySalary()가 게터 없이 직접 출력하는 예제가 friend 키워드의 대표 실전 활용 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A friend function reading a private member directly, with no getter needed (C++):
|
||||
```cpp
|
||||
class Employee {
|
||||
private:
|
||||
int salary;
|
||||
public:
|
||||
Employee(int s) { salary = s; }
|
||||
friend void displaySalary(Employee emp); // friend declaration
|
||||
};
|
||||
void displaySalary(Employee emp) { // defined outside, not a member
|
||||
cout << "Salary: " << emp.salary; // direct access to private data
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Virtual Functions]], [[CPP Encapsulation]], [[CPP Templates]]
|
||||
- **참조 맥락:** friend 함수 — 템플릿(Templates) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ The Friend Keyword — https://www.w3schools.com/cpp/cpp_friend_function.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ The Friend Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-function-array
|
||||
title: "C++ Pass Array to a Function"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array parameter", "C++ 배열을 함수로 전달"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "arrays"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_array.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Pass Array to a Function]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Calling `myFunction(myNumbers)` only needs the ARRAY NAME, but the function's own parameter must still spell out the full declaration (`int myNumbers[5]`) — the same asymmetry from C's identical chapter, confirming this array-name-is-a-pointer behavior carries over from C to C++ completely unmodified. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Passing arrays** — call site uses just the array name; the function signature needs the full array declaration. [S1]
|
||||
- **Same asymmetry as C** — bare name at the call site, full type+size at the parameter declaration. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Passing and looping through an array parameter: `void myFunction(int myNumbers[5]) { for (int i = 0; i < 5; i++) { cout << myNumbers[i] << "\n"; } } int myNumbers[5] = {10,20,30,40,50}; myFunction(myNumbers);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 배열-함수 매개변수 관계가 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 숫자 배열을 함수에 전달해 순회 출력하는 패턴이 배열-함수 결합의 기본 실전 활용이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Passing an array to a function using just its name at the call site (C++):
|
||||
```cpp
|
||||
void myFunction(int myNumbers[5]) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
cout << myNumbers[i] << "\n";
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
int myNumbers[5] = {10, 20, 30, 40, 50};
|
||||
myFunction(myNumbers);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function RealLife]], [[CPP Function Reference]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** 배열을 함수로 전달 — 참조로 전달(Function Reference) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Pass Array to a Function — https://www.w3schools.com/cpp/cpp_function_array.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Pass Array to a Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-function-default
|
||||
title: "C++ Default Parameters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["optional parameter", "default argument value", "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", "functions", "default-parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_default.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Default Parameters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This is a feature C never had — a function parameter can carry a FALLBACK VALUE (`string country = "Norway"`) that's automatically used ONLY when the caller omits that argument entirely, meaning `myFunction()` and `myFunction("USA")` are BOTH valid calls to the SAME function with different effective parameter counts, something C's rigid argument-count matching never permitted. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Default parameter value (`param = value`)** — assigns a fallback value used when the caller omits that argument. [S1]
|
||||
- **"Optional parameter"** — the common name for a parameter with a default value. [S1]
|
||||
- **Callable with or without the argument** — the SAME function accepts calls with a different number of arguments, unlike C where argument count must always match parameter count exactly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Default value used when the argument is omitted: `void myFunction(string country = "Norway") { cout << country << "\n"; } myFunction("Sweden"); // Sweden myFunction("India"); // India myFunction(); // Norway (default) myFunction("USA"); // USA`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C에는 없던 기본 매개변수 기능**: 인자를 생략하면 자동으로 기본값이 쓰이는 "선택적 매개변수(optional parameter)"는 C의 고정된 인자 개수 일치 규칙과 달리, 같은 함수를 다른 개수의 인자로 호출할 수 있게 해준다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 국가 매개변수를 생략하면 "Norway"가 기본으로 쓰이는 예제가 선택적 매개변수의 실전 활용을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A default parameter value used when the argument is omitted (C++):
|
||||
```cpp
|
||||
void myFunction(string country = "Norway") {
|
||||
cout << country << "\n";
|
||||
}
|
||||
int main() {
|
||||
myFunction("Sweden"); // Sweden
|
||||
myFunction(); // Norway (default used)
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Param]], [[CPP Function Overloading]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** 기본 매개변수 — 함수 오버로딩(Function Overloading) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Default Parameters — https://www.w3schools.com/cpp/cpp_function_default.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Default Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-function-multiple
|
||||
title: "C++ Multiple Parameters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["argument order matters", "C++ 다중 매개변수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_multiple.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Multiple Parameters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Mixing a `string` and an `int` parameter in one signature (`myFunction(string fname, int age)`) works with no special handling — reinforcing that C++'s type system lets DIFFERENT types coexist freely as sibling parameters, unlike C where mixing a `char[]` string parameter with an `int` required careful array-size declarations for the string slot specifically. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multiple, mixed-type parameters** — `void myFunction(string fname, int age)` combines a string and an int with no special syntax. [S1]
|
||||
- **Argument count and order must match** — the function call must supply the SAME NUMBER of arguments as parameters, IN THE SAME ORDER. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A string+int parameter pair reused across calls: `void myFunction(string fname, int age) { cout << fname << " Refsnes. " << age << " years old. \n"; } myFunction("Liam", 3); myFunction("Jenny", 14);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이름과 나이를 함께 받아 "OO는 N살입니다"를 출력하는 패턴이 실전 다중 매개변수 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A function combining a string and int parameter (C++):
|
||||
```cpp
|
||||
void myFunction(string fname, int age) {
|
||||
cout << fname << " Refsnes. " << age << " years old. \n";
|
||||
}
|
||||
int main() {
|
||||
myFunction("Liam", 3);
|
||||
myFunction("Jenny", 14);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Overloading]], [[CPP Function Return]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** 다중 매개변수 — return 키워드(Function Return) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Multiple Parameters — https://www.w3schools.com/cpp/cpp_function_multiple.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Multiple Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-function-overloading
|
||||
title: "C++ Function Overloading"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["same name different signature", "overload resolution", "C++ 함수 오버로딩"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "overloading"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_overloading.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Function Overloading]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Function overloading is entirely absent from C — C requires a UNIQUE name per function (hence `plusFuncInt`/`plusFuncDouble` as the "without overloading" workaround), while C++ lets MULTIPLE functions share one name (`plusFunc`) as long as their parameter TYPE or COUNT differs, meaning the compiler determines which version to call based on the ARGUMENTS at each call site, not the function name alone — a genuinely new resolution mechanism C never had. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Function overloading** — multiple functions sharing ONE NAME, differentiated by parameter type and/or count. [S1]
|
||||
- **Without overloading (the C-style workaround)** — separate function names (`plusFuncInt`, `plusFuncDouble`) needed for logically identical operations on different types. [S1]
|
||||
- **Overloading by type** — `int plusFunc(int x, int y)` and `double plusFunc(double x, double y)` coexist under one name. [S1]
|
||||
- **Overloading by parameter count** — `int plusFunc(int x, int y)` and `int plusFunc(int x, int y, int z)` coexist, differentiated purely by how many arguments are passed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The C-style workaround requiring separate names: `int plusFuncInt(int x, int y) { return x + y; } double plusFuncDouble(double x, double y) { return x + y; }`. [S1]
|
||||
- The same logic unified via overloading: `int plusFunc(int x, int y) { return x + y; } double plusFunc(double x, double y) { return x + y; }` — the compiler picks the right one based on argument types. [S1]
|
||||
- Overloading by parameter count: `int plusFunc(int x, int y) { return x + y; } int plusFunc(int x, int y, int z) { return x + y + z; }` — `plusFunc(3, 7)` calls the 2-parameter version, `plusFunc(1, 2, 3)` calls the 3-parameter version. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C에는 전혀 없던 오버로딩 개념**: C는 함수마다 고유한 이름이 필요하지만(plusFuncInt/plusFuncDouble처럼), C++는 매개변수의 타입이나 개수만 다르면 같은 이름을 여러 함수에 재사용할 수 있다는 점이 근본적으로 새로운 개념으로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
int과 double 두 타입에 대해 같은 덧셈 로직을 하나의 plusFunc 이름으로 통합하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
One function name overloaded for two different parameter types (C++):
|
||||
```cpp
|
||||
int plusFunc(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
double plusFunc(double x, double y) {
|
||||
return x + y;
|
||||
}
|
||||
int main() {
|
||||
int myNum1 = plusFunc(8, 5); // calls the int version
|
||||
double myNum2 = plusFunc(4.3, 6.26); // calls the double version
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Default]], [[CPP Function Multiple]], [[CPP Constructors Overloading]]
|
||||
- **참조 맥락:** 함수 오버로딩 — 다중 매개변수(Function Multiple) 챕터로 이어짐, 생성자 오버로딩(Constructors Overloading) 챕터와 직접 연결.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Function Overloading — https://www.w3schools.com/cpp/cpp_function_overloading.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Function Overloading" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-function-param
|
||||
title: "C++ Function Parameters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["parameters vs arguments", "C++ 함수 매개변수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_param.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Function Parameters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Passing a `string` parameter directly (`myFunction(string fname)`) requires NO special array-declaration syntax the way C would (where a string parameter needs `char name[]`) — confirming that C++'s genuine string type flows naturally into function signatures too, letting a function accept and concatenate names as simply as it would numbers. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Parameter vs. argument** — parameter is the variable name in the signature; argument is the actual value passed at the call site. [S1]
|
||||
- **String parameters work directly** — `void myFunction(string fname)`, no array declaration needed unlike C. [S1]
|
||||
- **Reused function logic across calls** — the same function body runs once per call with different arguments. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A string parameter reused across three calls: `void myFunction(string fname) { cout << fname << " Refsnes\n"; } myFunction("Liam"); myFunction("Jenny"); myFunction("Anja");` — each call appends " Refsnes" to a different name. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **string 매개변수에 배열 문법이 필요 없음**: C에서는 문자열 매개변수를 char name[]으로 선언해야 했지만, C++에서는 string fname처럼 직접 선언 가능하다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이름 뒤에 성(Refsnes)을 자동으로 붙여 출력하는 예제가 문자열 매개변수 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A string parameter used directly, no array syntax needed (C++):
|
||||
```cpp
|
||||
void myFunction(string fname) {
|
||||
cout << fname << " Refsnes\n";
|
||||
}
|
||||
int main() {
|
||||
myFunction("Liam");
|
||||
myFunction("Jenny");
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Functions]], [[CPP Function Default]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** 함수 매개변수 — 기본 매개변수(Function Default) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Function Parameters — https://www.w3schools.com/cpp/cpp_function_param.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Function Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-function-reallife
|
||||
title: "C++ Function Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fahrenheit to celsius", "C++ 함수 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.81
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Function Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The identical Fahrenheit-to-Celsius conversion example from C reappears in C++ unchanged, right down to the same formula and variable names — confirming that a pure computational function (no strings, no OOP, no C++-specific features) transfers between the two languages with essentially zero adaptation beyond `cout <<` replacing `printf()`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **A function encapsulating one formula** — `toCelsius(fahrenheit)` hides the `(5.0/9.0) * (fahrenheit - 32.0)` computation behind a clear name. [S1]
|
||||
- **Reused pattern from C** — identical structure to C's Fahrenheit/Celsius example. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The conversion function and its usage: `float toCelsius(float fahrenheit) { return (5.0 / 9.0) * (fahrenheit - 32.0); } float f_value = 98.8; float result = toCelsius(f_value);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 예제임이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
화씨를 섭씨로 변환하는 toCelsius() 함수가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A function encapsulating the Fahrenheit-to-Celsius formula (C++):
|
||||
```cpp
|
||||
float toCelsius(float fahrenheit) {
|
||||
return (5.0 / 9.0) * (fahrenheit - 32.0);
|
||||
}
|
||||
int main() {
|
||||
float f_value = 98.8;
|
||||
float result = toCelsius(f_value);
|
||||
cout << "Convert Fahrenheit to Celsius: " << result << "\n";
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.81
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Return]], [[CPP Function Array]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** 함수 실전 예제 — 배열을 함수로 전달하기(Function Array) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Function Examples — https://www.w3schools.com/cpp/cpp_function_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Function Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-function-reference
|
||||
title: "C++ Functions - Pass By Reference"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pass by reference", "swap function", "C++ 참조로 전달"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "references"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_reference.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Functions - Pass By Reference]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Passing a parameter as `int &num` lets a function PERMANENTLY change the caller's actual variable using ordinary assignment syntax (`num = 50;`) with no `*` dereference needed anywhere — a much simpler syntax than C's equivalent (which requires passing `&myCar` and using `->` inside the function) — showing that C++'s reference feature does the SAME job as C's pointer-parameter pattern but eliminates every pointer-specific symbol from both the call site and the function body. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`type ¶m`** — a reference parameter; the function receives an ALIAS to the caller's actual variable, not a copy. [S1]
|
||||
- **No dereference syntax needed** — unlike a pointer parameter, using `num` directly (no `*num`) reads or writes the caller's original variable. [S1]
|
||||
- **Swap pattern** — `void swapNums(int &x, int &y)` can swap the CALLER's two variables permanently, since both parameters are aliases to the originals. [S1]
|
||||
- **Works for any type, including `string`** — `void modifyStr(string &str)` mutates the caller's original string. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Changing a caller's variable through a reference parameter: `void changeValue(int &num) { num = 50; } int value = 10; changeValue(value); cout << value; // 50`. [S1]
|
||||
- Swapping two caller variables: `void swapNums(int &x, int &y) { int z = x; x = y; y = z; } swapNums(firstNum, secondNum); // firstNum and secondNum are now swapped`. [S1]
|
||||
- Mutating a string through a reference: `void modifyStr(string &str) { str += " World!"; } string greeting = "Hello"; modifyStr(greeting); cout << greeting; // "Hello World!"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **참조 전달은 포인터 전달보다 문법이 훨씬 간단함**: C에서는 &myCar로 넘기고 함수 안에서 ->로 접근해야 했지만, C++의 참조 매개변수는 & 없이 num처럼 직접 써서 원본 값을 바꿀 수 있다는 점에서 동일한 기능을 훨씬 단순한 문법으로 제공함이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
두 정수 변수의 값을 서로 맞바꾸는 swapNums() 함수가 참조 전달의 대표적인 실전 활용 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Swapping two of the caller's variables using reference parameters (C++):
|
||||
```cpp
|
||||
void swapNums(int &x, int &y) {
|
||||
int z = x;
|
||||
x = y;
|
||||
y = z;
|
||||
}
|
||||
int main() {
|
||||
int firstNum = 10;
|
||||
int secondNum = 20;
|
||||
swapNums(firstNum, secondNum); // both are permanently swapped
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Array]], [[CPP Function Structures]], [[CPP References]]
|
||||
- **참조 맥락:** 참조로 전달 — 구조체를 함수로 전달(Function Structures) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Functions - Pass By Reference — https://www.w3schools.com/cpp/cpp_function_reference.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Functions - Pass By Reference" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: cpp-function-return
|
||||
title: "C++ The Return Keyword"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["return values", "void vs typed return", "C++ return 키워드"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "return"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_return.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP The Return Keyword]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The "doubling game" example calls `doubleGame(i)` DIRECTLY inside a `cout <<` chain (`cout << "Double of " << i << " is " << doubleGame(i) << endl;`) without ever storing the return value in a variable first — proving a function call's return value can be used as an EXPRESSION anywhere a value is expected, not just assigned to a variable, letting five separate function calls (one per loop iteration) feed directly into output formatting. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`void` vs. a real return type** — `void` means no return value; a real type (`int`, etc.) plus `return` lets the function hand back a computed value. [S1]
|
||||
- **Using a function call inline** — a function's return value can be used directly inside an expression (like a `cout <<` chain) without first storing it in a variable. [S1]
|
||||
- **Storing the result in a variable** — equally valid, and often clearer for reuse. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Returning a computed value: `int myFunction(int x) { return 5 + x; } cout << myFunction(3); // 8`. [S1]
|
||||
- Storing the result before printing: `int z = myFunction(5, 3); cout << z;`. [S1]
|
||||
- Using the return value directly inline inside a loop, with no intermediate variable: `int doubleGame(int x) { return x * 2; } for (int i = 1; i <= 5; i++) { cout << "Double of " << i << " is " << doubleGame(i) << endl; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
1부터 5까지 각 숫자를 두 배로 만들어 출력하는 "게임" 예제가 함수 반환값을 변수에 저장하지 않고 cout 문 안에서 바로 사용하는 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Using a function's return value directly inline inside a loop's output, without an intermediate variable (C++):
|
||||
```cpp
|
||||
int doubleGame(int x) {
|
||||
return x * 2;
|
||||
}
|
||||
int main() {
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
cout << "Double of " << i << " is " << doubleGame(i) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Multiple]], [[CPP Function RealLife]], [[C Functions Parameters]]
|
||||
- **참조 맥락:** return 키워드 — 함수 실전 예제(Function RealLife) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ The Return Keyword — https://www.w3schools.com/cpp/cpp_function_return.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ The Return Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-function-structures
|
||||
title: "C++ Pass Structures to a Function"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pass by value struct", "pass by reference struct", "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", "functions", "structs"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_structures.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Pass Structures to a Function]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Passing a struct WITHOUT `&` gives the function a full COPY — mutating it inside the function leaves the caller's original untouched — while passing it WITH `&` gives the function the ORIGINAL, letting `c.year++;` permanently increment the caller's struct field, meaning the exact same `&` reference syntax from the Pass By Reference chapter extends naturally to entire structs, not just primitive types like `int`/`string`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Pass by value (default)** — `void myFunction(Car c)` gives the function a COPY of the struct; modifying `c` inside the function does NOT affect the caller's original. [S1]
|
||||
- **Pass by reference (`Car &c`)** — gives the function the ORIGINAL struct; modifications inside the function DO persist in the caller. [S1]
|
||||
- **When to use reference** — to let the function change the struct's data, OR to avoid copying large structures (performance). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Pass by value — original unaffected: `struct Car { string brand; int year; }; void myFunction(Car c) { cout << "Brand: " << c.brand << ", Year: " << c.year << "\n"; } Car myCar = {"Toyota", 2020}; myFunction(myCar); // myCar unchanged after this call`. [S1]
|
||||
- Pass by reference — original mutated: `void updateYear(Car &c) { c.year++; } Car myCar = {"Toyota", 2020}; updateYear(myCar); cout << myCar.year; // 2021 — the original was incremented`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **값 전달과 참조 전달의 결과 차이**: & 없이 구조체를 전달하면 함수는 복사본을 받아 원본이 바뀌지 않지만, &를 붙이면 원본 자체를 받아 함수 안의 변경이 그대로 유지된다는 점이 year++ 예제로 직접 대비되어 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
자동차 구조체의 연식(year)을 참조로 전달받아 함수 안에서 1씩 증가시키고 그 변경이 원본에 반영되는 updateYear() 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Passing a struct by reference so the function can permanently modify it (C++):
|
||||
```cpp
|
||||
struct Car {
|
||||
string brand;
|
||||
int year;
|
||||
};
|
||||
void updateYear(Car &c) {
|
||||
c.year++;
|
||||
}
|
||||
int main() {
|
||||
Car myCar = {"Toyota", 2020};
|
||||
updateYear(myCar);
|
||||
cout << "The " << myCar.brand << " is now from year " << myCar.year << "."; // 2021
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Reference]], [[CPP Functions Recursion]], [[CPP Structs]]
|
||||
- **참조 맥락:** 구조체를 함수로 전달 — 재귀(Functions Recursion) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Pass Structures to a Function — https://www.w3schools.com/cpp/cpp_function_structures.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Pass Structures to a Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: cpp-functions
|
||||
title: "C++ Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["void function", "function call", "declaration order matters", "C++ 함수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Calling a function BEFORE it's defined (with no prior declaration) is an explicit ERROR in C++ — the source shows `myFunction()` called inside `main()` at the top, with its full definition written BELOW, producing a compile error — a stricter behavior than what C-style top-down reading might suggest, meaning the declaration-above/definition-below organizational pattern isn't just a style preference here, it's the FIX for a real compile failure, not merely cosmetic. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Function** — a block of code that only runs when CALLED. [S1]
|
||||
- **`void` return type** — the function returns no value. [S1]
|
||||
- **Calling before defining fails without a declaration** — if `myFunction()` is called in `main()` but only DEFINED below `main()` with no prior declaration, it's a compile error. [S1]
|
||||
- **Declaration + definition split** — writing `void myFunction();` above `main()` and the full body below fixes the ordering problem while keeping code organized. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The error case (calling before any declaration exists): `int main() { myFunction(); return 0; } void myFunction() { cout << "..."; } // Error`. [S1]
|
||||
- The fix using forward declaration: `void myFunction(); int main() { myFunction(); return 0; } void myFunction() { cout << "I just got executed!"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **선언 없이 정의보다 먼저 호출하면 명시적 에러**: main() 안에서 함수를 호출하고 그 정의가 아래에 있을 뿐 사전 선언이 없으면 컴파일 에러가 발생한다는 점이 직접 예시로 확인됨 — C 챕터보다 이 문제를 더 명확히 강조함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 함수 선언을 main() 위에 두고 정의를 아래에 두는 구조가 컴파일 에러를 피하면서 코드 가독성도 높이는 실전 표준 관행이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Forward-declaring a function above main() so it can be called before its full definition (C++):
|
||||
```cpp
|
||||
// Function declaration
|
||||
void myFunction();
|
||||
|
||||
int main() {
|
||||
myFunction(); // works because of the forward declaration above
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Function definition
|
||||
void myFunction() {
|
||||
cout << "I just got executed!";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Memory Management New]], [[CPP Function Param]], [[C Functions]]
|
||||
- **참조 맥락:** 함수 섹션 첫 챕터 — 함수 매개변수(Function Param) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Functions — https://www.w3schools.com/cpp/cpp_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: cpp-functions-lambda
|
||||
title: "C++ Lambda Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["anonymous function", "capture clause", "capture by value vs reference", "C++ 람다 함수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "lambda"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_functions_lambda.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Lambda Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The capture clause's TWO forms — `[x]` (by value, a frozen COPY at the moment of creation) versus `[&x]` (by reference, always the LATEST value) — produce genuinely different output for the identical-looking code: the same `show()` lambda prints `10` in one version and `20` in the other, purely because `x` was changed to 20 AFTER the lambda was defined — meaning the capture-clause choice determines whether a lambda is a snapshot of the past or a live window into the present. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Lambda function** — `[capture](parameters) { code };` — an anonymous, throwaway function written inline, with no separate name/declaration required. [S1]
|
||||
- **`auto` + lambda** — a lambda is typically stored via `auto varName = [...]() {...};` then called like a normal function (`varName();`). [S1]
|
||||
- **Capture by value (`[x]`)** — the lambda gets a COPY of `x` frozen at creation time; later changes to the outer `x` don't affect the lambda's copy. [S1]
|
||||
- **Capture by reference (`[&x]`)** — the lambda uses the ORIGINAL `x`; it always sees the latest value, even changes made AFTER the lambda was defined. [S1]
|
||||
- **Passing a lambda as an argument** — requires `#include <functional>` and a `function<returnType(paramTypes)>` parameter type in the RECEIVING function. [S1]
|
||||
- **Regular function vs. lambda** — use a regular function when reused often, needs a clear name, or logic is long; use a lambda for one-off, short, throwaway logic or when passing behavior into another function. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic no-parameter lambda: `auto message = []() { cout << "Hello World!\n"; }; message();`. [S1]
|
||||
- Lambda with parameters: `auto add = [](int a, int b) { return a + b; }; cout << add(3, 4); // 7`. [S1]
|
||||
- Passing a lambda to another function: `void myFunction(function<void()> func) { func(); func(); } auto message = []() { cout << "Hello World!\n"; }; myFunction(message);` — requires `#include <functional>`. [S1]
|
||||
- Capture by value freezes the value at creation: `int x = 10; auto show = [x]() { cout << x; }; show(); // 10, even if x changes afterward`. [S1]
|
||||
- Capture by reference sees the LATEST value: `int x = 10; auto show = [&x]() { cout << x; }; x = 20; show(); // 20 — reflects the change made after the lambda was created`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **캡처 방식에 따라 동일한 코드가 다른 결과를 냄**: [x]로 값 캡처하면 람다 생성 시점의 x 값이 고정되지만, [&x]로 참조 캡처하면 이후 x가 바뀐 값을 그대로 반영한다는 점이 동일한 구조의 두 예제(10 vs 20 출력)로 직접 대비되어 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
반복문 안에서 매 순회마다 다른 값을 캡처하는 람다를 즉석에서 정의해 사용하는 패턴(`for (int i = 1; i <= 3; i++) { auto show = [i]() {...}; show(); }`)이 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Capture by value vs. capture by reference producing different output from identical-looking code (C++):
|
||||
```cpp
|
||||
int x = 10;
|
||||
auto showCopy = [x]() { cout << x; }; // captures a frozen copy
|
||||
auto showRef = [&x]() { cout << x; }; // captures the live variable
|
||||
x = 20;
|
||||
showCopy(); // 10 (unaffected by the later change)
|
||||
showRef(); // 20 (reflects the latest value)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Functions Recursion]], [[CPP References]], [[CPP OOP]]
|
||||
- **참조 맥락:** 함수 섹션 마지막 — 객체지향 프로그래밍 기초(OOP Basics) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Lambda Functions — https://www.w3schools.com/cpp/cpp_functions_lambda.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Lambda Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: cpp-functions-recursion
|
||||
title: "C++ Recursion"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["recursive function", "base case", "factorial recursion", "C++ 재귀"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "functions", "recursion"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_functions_recursion.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Recursion]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same three examples (range-sum via `sum(k)`, countdown, factorial) with the exact same step-by-step unfolding explanation reappear here verbatim from C's Recursion chapter — confirming C++'s recursion semantics, base-case requirement, and termination risks are inherited from C completely unmodified. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Recursion** — a function calling ITSELF, breaking a complex problem into smaller instances of the same problem. [S1]
|
||||
- **Base case** — the condition under which the function stops calling itself (`k > 0` becoming false), essential for termination. [S1]
|
||||
- **Unwinding accumulation** — each recursive call combines its own contribution with the result of the smaller sub-call. [S1]
|
||||
- **Risk of non-termination or excess resource use** — without a solid base case, recursion can run forever or exhaust memory/processor time. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Summing 1 to 10 via recursion: `int sum(int k) { if (k > 0) { return k + sum(k - 1); } else { return 0; } }` — unfolds as `10 + (9 + (8 + ... + sum(0)))`. [S1]
|
||||
- Countdown via recursion: `void countdown(int n) { if (n > 0) { cout << n << " "; countdown(n - 1); } }`. [S1]
|
||||
- Factorial via recursion: `int factorial(int n) { if (n > 1) { return n * factorial(n - 1); } else { return 1; } }` — factorial(5) = 120. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 재귀 예제와 설명이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
5의 팩토리얼(5×4×3×2×1=120)을 재귀로 계산하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A recursive function with a clear base case that guarantees termination (C++):
|
||||
```cpp
|
||||
int factorial(int n) {
|
||||
if (n > 1) {
|
||||
return n * factorial(n - 1);
|
||||
} else {
|
||||
return 1; // base case
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Function Structures]], [[CPP Functions Lambda]], [[C Functions Recursion]]
|
||||
- **참조 맥락:** 재귀 — 람다 함수(Functions Lambda) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Recursion — https://www.w3schools.com/cpp/cpp_functions_recursion.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Recursion" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-get-started
|
||||
title: "C++ Getting Started"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["installing cpp", "Code::Blocks setup", "C++ 시작하기"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "setup", "ide"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_getstarted.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Get Started]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same two-tool requirement from C (a text editor plus a separate compiler like GCC) carries over unchanged to C++ — reinforcing that C++'s compiled nature, not just its syntax, is inherited directly from C, and the recommended beginner workflow (Code::Blocks + MinGW, `.cpp` files, Build & Run) is nearly identical to the C tutorial's setup chapter with only the file extension and header differing. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Two required tools** — a text editor and a compiler (e.g. GCC) to translate C++ code into machine-understandable form. [S1]
|
||||
- **IDE bundling both** — Code::Blocks, Eclipse, Visual Studio package editor + compiler + debugging together. [S1]
|
||||
- **`.cpp` file extension** — C++ source files are saved with `.cpp`, distinct from C's `.c`. [S1]
|
||||
- **Web-based editors work but are limited** — same caveat as the C tutorial's setup chapter. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The verification program used to confirm a working setup: `#include <iostream> using namespace std; int main() { cout << "Hello World!"; return 0; }` saved as `myfirstprogram.cpp`. [S1]
|
||||
- Recommended IDE and installer: Code::Blocks via the `mingw-setup.exe` installer (bundles editor + compiler). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Code::Blocks + MinGW 조합이 C 튜토리얼과 동일하게 C++ 초보자 환경 구축의 표준 방법으로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The verification program used to confirm a working C++ compiler setup:
|
||||
```cpp
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main() {
|
||||
cout << "Hello World!";
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Intro]], [[CPP Syntax]], [[C Get Started]]
|
||||
- **참조 맥락:** 개발 환경 설정 — 문법(Syntax) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Getting Started — https://www.w3schools.com/cpp/cpp_getstarted.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Getting Started" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: cpp-inheritance
|
||||
title: "C++ Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["base class", "derived class", "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", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_inheritance.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `Car` class never declares a `brand` attribute or a `honk()` method of its own — it inherits BOTH directly from `Vehicle` via the single `: public Vehicle` syntax, and `myCar.honk()` works exactly as if `honk()` had been written inside `Car` itself, meaning inheritance in C++ isn't a reference or delegation mechanism but a literal MERGING of the parent's members into the child, accessible with zero extra syntax at the call site. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Inheritance** — one class (derived/child) reuses attributes and methods from another (base/parent), avoiding duplication. [S1]
|
||||
- **`: public BaseClass`** — the syntax for inheriting; placed after the derived class's name. [S1]
|
||||
- **Zero-syntax access to inherited members** — a child object calls inherited methods and reads inherited attributes exactly like its own, with no special prefix. [S1]
|
||||
- **Why inherit** — code reusability — reuse an existing class's attributes/methods when creating a new one. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A child class inheriting an attribute and method from its parent: `class Vehicle { public: string brand = "Ford"; void honk() { cout << "Tuut, tuut! \n"; } }; class Car: public Vehicle { public: string model = "Mustang"; }; Car myCar; myCar.honk(); // inherited from Vehicle cout << myCar.brand + " " + myCar.model; // brand inherited, model is Car's own`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Vehicle의 brand와 honk()를 Car가 그대로 물려받는 예제가 상속을 통한 코드 재사용의 대표 실전 활용이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A child class inheriting an attribute and method from its parent with zero extra syntax (C++):
|
||||
```cpp
|
||||
class Vehicle { // Base class
|
||||
public:
|
||||
string brand = "Ford";
|
||||
void honk() { cout << "Tuut, tuut! \n"; }
|
||||
};
|
||||
class Car: public Vehicle { // Derived class
|
||||
public:
|
||||
string model = "Mustang";
|
||||
};
|
||||
int main() {
|
||||
Car myCar;
|
||||
myCar.honk(); // inherited method, works directly
|
||||
cout << myCar.brand + " " + myCar.model;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Encapsulation]], [[CPP Inheritance Access]]
|
||||
- **참조 맥락:** 상속 섹션 첫 챕터 — 상속 접근 지정자(Inheritance Access) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Inheritance — https://www.w3schools.com/cpp/cpp_inheritance.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-inheritance-access
|
||||
title: "C++ Inheritance Access"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["protected access specifier", "C++ 상속과 protected"]
|
||||
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", "inheritance", "protected"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_inheritance_access.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Inheritance Access]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter reveals WHY `protected` exists as a third option distinct from `private`: a `private` attribute in the base class would be completely UNREACHABLE by the derived class's own methods, forcing awkward workarounds, while `protected` lets `Programmer`'s `setSalary()`/`getSalary()` methods directly manipulate `Employee`'s `salary` field as if it were their own — meaning `protected` specifically solves the "I need child classes to touch this, but nobody else" access pattern that neither `public` nor `private` alone can express. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`protected`** — similar to `private` (inaccessible from OUTSIDE the class), but UNLIKE `private`, accessible from DERIVED (child) classes. [S1]
|
||||
- **Derived-class methods manipulating a protected base attribute** — `Programmer`'s `setSalary()`/`getSalary()` methods read/write `Employee`'s `protected int salary;` directly, as if it belonged to `Programmer`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A protected base attribute manipulated by a derived class's own methods: `class Employee { protected: int salary; }; class Programmer: public Employee { public: int bonus; void setSalary(int s) { salary = s; } int getSalary() { return salary; } }; Programmer myObj; myObj.setSalary(50000); myObj.bonus = 15000;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **protected는 private과 public 사이의 중간 지점**: 클래스 외부에서는 접근 불가하다는 점에서 private과 같지만, 파생 클래스에서는 접근 가능하다는 점에서 다르다는 것이 확인됨 — 이는 private만으로는 해결 못 하는 "자식 클래스만 접근 허용" 요구를 해결. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Employee의 protected 급여(salary)를 Programmer 파생 클래스가 자체 getter/setter로 직접 다루는 예제가 protected의 대표 실전 활용 사례로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A protected base attribute directly manipulated by a derived class's own methods (C++):
|
||||
```cpp
|
||||
class Employee {
|
||||
protected: // accessible in derived classes, not outside
|
||||
int salary;
|
||||
};
|
||||
class Programmer: public Employee {
|
||||
public:
|
||||
int bonus;
|
||||
void setSalary(int s) { salary = s; }
|
||||
int getSalary() { return salary; }
|
||||
};
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Inheritance]], [[CPP Access Specifiers]], [[CPP Inheritance Multilevel]]
|
||||
- **참조 맥락:** 상속과 protected — 다단계 상속(Inheritance Multilevel) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Inheritance Access — https://www.w3schools.com/cpp/cpp_inheritance_access.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Inheritance Access" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: cpp-inheritance-multilevel
|
||||
title: "C++ Multilevel Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["grandchild class", "chained inheritance", "C++ 다단계 상속"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Multilevel Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`MyGrandChild` never mentions `MyClass` anywhere in its own declaration — it only inherits from `MyChild`, yet calling `myFunction()` (defined in `MyClass`) works perfectly, proving inheritance CHAINS transitively: a grandchild automatically gets everything its parent has, INCLUDING whatever the parent itself inherited, without needing to re-declare or re-reference the original ancestor at any point in the chain. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multilevel inheritance** — a class derived from ANOTHER derived class (a chain: grandparent → parent → child). [S1]
|
||||
- **Transitive inheritance** — the grandchild class automatically has access to the ORIGINAL base class's members, even though it never directly references that base class. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A three-level inheritance chain: `class MyClass { public: void myFunction() { cout << "Some content in parent class."; } }; class MyChild: public MyClass { }; class MyGrandChild: public MyChild { }; MyGrandChild myObj; myObj.myFunction(); // works, inherited transitively through MyChild`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **상속은 전이적(transitive)으로 작동**: 손자 클래스가 원래의 베이스 클래스를 전혀 언급하지 않아도, 부모를 거쳐 그 기능을 자동으로 물려받는다는 점이 직접 예제로 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — MyClass → MyChild → MyGrandChild의 3단계 상속 체인이 다단계 상속의 개념적 골격을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A three-level inheritance chain — the grandchild inherits transitively (C++):
|
||||
```cpp
|
||||
class MyClass { // grandparent
|
||||
public:
|
||||
void myFunction() { cout << "Some content in parent class."; }
|
||||
};
|
||||
class MyChild: public MyClass { }; // parent
|
||||
class MyGrandChild: public MyChild { }; // child
|
||||
int main() {
|
||||
MyGrandChild myObj;
|
||||
myObj.myFunction(); // works via the full chain
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Inheritance Access]], [[CPP Inheritance Multiple]]
|
||||
- **참조 맥락:** 다단계 상속 — 다중 상속(Inheritance Multiple) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Multilevel Inheritance — https://www.w3schools.com/cpp/cpp_inheritance_multilevel.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Multilevel Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: cpp-inheritance-multiple
|
||||
title: "C++ Multiple Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["comma-separated base classes", "C++ 다중 상속"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_inheritance_multiple.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Multiple Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Multiple inheritance is a feature with NO equivalent in most single-inheritance-only OOP languages — one class can inherit from TWO unrelated base classes simultaneously via a comma-separated list (`class MyChildClass: public MyClass, public MyOtherClass`), gaining methods from BOTH parents at once, unlike multilevel inheritance's single linear chain from the previous chapter. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multiple inheritance** — a class derived from MORE THAN ONE base class, listed comma-separated after `:`. [S1]
|
||||
- **Distinct from multilevel inheritance** — multilevel is a linear CHAIN (grandparent→parent→child); multiple inheritance is a class combining SEPARATE, unrelated base classes at the SAME level. [S1]
|
||||
- **Access to all parents' members** — the derived class gains every public method/attribute from EACH listed base class. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- A class inheriting from two unrelated base classes: `class MyClass { public: void myFunction() { cout << "Some content in parent class."; } }; class MyOtherClass { public: void myOtherFunction() { cout << "Some content in another class."; } }; class MyChildClass: public MyClass, public MyOtherClass { }; MyChildClass myObj; myObj.myFunction(); myObj.myOtherFunction(); // both work`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **다중 상속은 다단계 상속과 다른 개념**: 다단계 상속이 부모→자식→손자의 선형 체인이라면, 다중 상속은 서로 무관한 두 베이스 클래스를 같은 단계에서 동시에 상속받는 것이라는 점이 명확히 구분됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — MyClass와 MyOtherClass 양쪽의 메서드를 모두 물려받는 MyChildClass 예제가 다중 상속의 개념적 골격을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A class inheriting from two unrelated base classes at once (C++):
|
||||
```cpp
|
||||
class MyClass {
|
||||
public:
|
||||
void myFunction() { cout << "Some content in parent class."; }
|
||||
};
|
||||
class MyOtherClass {
|
||||
public:
|
||||
void myOtherFunction() { cout << "Some content in another class."; }
|
||||
};
|
||||
class MyChildClass: public MyClass, public MyOtherClass { };
|
||||
int main() {
|
||||
MyChildClass myObj;
|
||||
myObj.myFunction(); // from MyClass
|
||||
myObj.myOtherFunction(); // from MyOtherClass
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Inheritance Multilevel]], [[CPP Polymorphism]]
|
||||
- **참조 맥락:** 상속 섹션 마지막 — 다형성 및 고급 OOP(Polymorphism & Advanced OOP) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Multiple Inheritance — https://www.w3schools.com/cpp/cpp_inheritance_multiple.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Multiple Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: cpp-input-validation
|
||||
title: "C++ Input Validation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["cin.clear cin.ignore", "validate integer input", "C++ 입력 검증"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "input-validation", "cin"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_input_validation.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Input Validation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`while (!(cin >> number))` works because `cin >>` ITSELF evaluates to a boolean-like failure state when the parse fails — but a FAILED `cin >>` doesn't just fail cleanly, it leaves the STREAM in an error state AND the bad characters still sitting in the input buffer, which is why the fix requires TWO separate repair steps (`cin.clear()` to reset the error flag, `cin.ignore(10000, '\n')` to discard the leftover bad input) — a two-part cleanup ritual with no equivalent in C's simpler `fgets()`+`sscanf()` validation approach. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`cin >> number` as a validity check** — the expression itself is falsy when the input can't be parsed as the target type, usable directly in a `while (!(cin >> number))` loop. [S1]
|
||||
- **`cin.clear()`** — resets the stream's internal error flags after a failed read, WITHOUT which the stream stays "stuck" in a failed state. [S1]
|
||||
- **`cin.ignore(10000, '\n')`** — discards up to 10000 leftover characters (or until a newline), removing the bad input that caused the failure so the next read isn't corrupted. [S1]
|
||||
- **Range validation via do-while** — same pattern as C, repeatedly prompting until the value falls within bounds. [S1]
|
||||
- **Empty-text validation via `.empty()`** — `string.empty()` checks directly whether a string is blank, cleaner than C's `strlen(name) == 0` check. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full integer-validation loop with the required two-step cleanup: `int number; while (!(cin >> number)) { cout << "Invalid input. Try again: "; cin.clear(); cin.ignore(10000, '\n'); }`. [S1]
|
||||
- Range-bounded input: `int number; do { cin >> number; } while (number < 1 || number > 5);`. [S1]
|
||||
- Empty-text rejection using `.empty()`: `string name; do { getline(cin, name); } while (name.empty());`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **cin 실패 시 두 단계 복구가 필요함**: 파싱에 실패하면 스트림이 에러 상태에 갇히고 잘못된 입력이 버퍼에 남으므로, cin.clear()로 에러 플래그를 초기화하고 cin.ignore()로 남은 잘못된 입력을 제거하는 두 단계가 모두 필요하다는 점이 C의 fgets+sscanf 방식보다 복잡한 절차로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
문자를 입력했을 때 "Invalid input. Try again"을 출력하고 다시 물어보는 정수 입력 검증 루프가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Validating integer input with the required two-step stream cleanup after a failed parse (C++):
|
||||
```cpp
|
||||
int number;
|
||||
cout << "Enter a number: ";
|
||||
while (!(cin >> number)) {
|
||||
cout << "Invalid input. Try again: ";
|
||||
cin.clear(); // Reset input errors
|
||||
cin.ignore(10000, '\n'); // Remove bad input
|
||||
}
|
||||
cout << "You entered: " << number;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Exceptions]], [[CPP User Input]], [[CPP Debugging]]
|
||||
- **참조 맥락:** 입력 검증 — 디버깅(Debugging) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Input Validation — https://www.w3schools.com/cpp/cpp_input_validation.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Input Validation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: cpp-intro
|
||||
title: "C++ Introduction"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["what is cpp", "C vs C++", "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", "intro"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source reduces the entire C vs C++ distinction to ONE sentence — "C++ supports classes and objects, while C does not" — meaning everything else commonly associated with C++ (templates, STL, inheritance, polymorphism) is really downstream consequence of that single foundational addition, not a separate list of unrelated features layered onto C. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Origin** — created by Bjarne Stroustrup as an extension of C. [S1]
|
||||
- **Major version history** — updated 5 times: C++11, C++14, C++17, C++20, C++23 (2011/2014/2017/2020/2023). [S1]
|
||||
- **Cross-platform, high-performance** — used in operating systems, GUIs, and embedded systems. [S1]
|
||||
- **Object-oriented** — gives clear program structure and enables code reuse, lowering development cost. [S1]
|
||||
- **The single core C vs C++ difference** — C++ supports classes and objects; C does not. Nearly identical syntax otherwise. [S1]
|
||||
- **Proximity to C/C#/Java** — makes switching between these languages and C++ relatively easy. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- C++'s five major standard revisions listed explicitly: C++11 (2011), C++14 (2014), C++17 (2017), C++20 (2020), C++23 (2023). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 운영체제, GUI, 임베디드 시스템이 원문에서 언급된 C++의 대표적 실전 활용 분야다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
None — this is a conceptual overview page with no standalone code example.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[C Intro]], [[CPP Get Started]]
|
||||
- **참조 맥락:** C++ 튜토리얼 첫 챕터 — 개발 환경 설정(Get Started) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Introduction — https://www.w3schools.com/cpp/cpp_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Introduction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: cpp-iterators
|
||||
title: "C++ Iterators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["begin() end()", "vector iterator", "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", "stl", "iterator"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_iterators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Iterators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An iterator is a pointer with a container-agnostic interface — `*it` dereferences and `++it` advances exactly like a raw C pointer walking an array, but the SAME `begin()`/`end()`/`*it`/`++it` syntax works identically across vector, list, deque, set, AND map, which is precisely the capability C's raw pointers never had (a `int*` walking an array shares no interface with a linked-list traversal via `node->next`) — and this uniform interface is *why* for-each loops and generic algorithms like `sort()`/`find()` can operate on any container without being rewritten per container type. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Iterator = a "pointer" to an element** — used to access/iterate through data structures by pointing to elements rather than copying them. [S1]
|
||||
- **`begin()` / `end()`** — functions belonging to the CONTAINER (not the iterator) that return an iterator to the first element / to one-past-the-last element; `end()` never points to a real element, only marks the stopping condition. [S1]
|
||||
- **`*it`** — dereference operator, accesses the value the iterator currently points to (and can assign through it: `*it = "Tesla";` modifies the container in place). [S1]
|
||||
- **`++it`** — advances the iterator to the next element. [S1]
|
||||
- **`auto` keyword** — lets the compiler infer the verbose iterator type (`vector<string>::iterator`) automatically; works in the loop declaration itself. [S1]
|
||||
- **For-each vs. iterator** — for-each is simpler for read-only traversal; iterators are required when you need to modify, erase, iterate in reverse, or skip elements during the loop. [S1]
|
||||
- **`.erase(it)` inside a loop** — removing an element mid-iteration returns the NEXT valid iterator, which is why the erase-loop pattern reassigns `it = cars.erase(it);` instead of also calling `++it`. [S1]
|
||||
- **`rbegin()` / `rend()`** — reverse-order counterparts to `begin()`/`end()`, for iterating backward. [S1]
|
||||
- **Iterator support is not universal** — vector, list, deque, map, and set support iterators; stack and queue do NOT. [S1]
|
||||
- **Iterators power `<algorithm>` functions** — `sort()`, `find()`, etc. take a begin/end iterator pair as parameters rather than the container itself. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic loop: `vector<string>::iterator it; for (it = cars.begin(); it != cars.end(); ++it) { cout << *it; }`. [S1]
|
||||
- `auto` shorthand: `for (auto it = cars.begin(); it != cars.end(); ++it) { cout << *it; }`. [S1]
|
||||
- Erase-during-iteration pattern: `for (auto it = cars.begin(); it != cars.end(); ) { if (*it == "BMW") { it = cars.erase(it); } else { ++it; } }` — no `++it` in the header since erase already advances. [S1]
|
||||
- Reverse iteration: `for (auto it = cars.rbegin(); it != cars.rend(); ++it) { cout << *it; }`. [S1]
|
||||
- Map iteration needs `->first`/`->second` (arrow, since `it` is a pointer-like object to a pair): `for (auto it = people.begin(); it != people.end(); ++it) { cout << it->first << it->second; }`. [S1]
|
||||
- `sort(cars.begin(), cars.end());` from `<algorithm>` — the same begin/end pair used for manual loops is reused as the algorithm's range argument. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C의 원시 포인터에는 없던 통일 인터페이스가 도입됨**: C에서 배열은 포인터 산술(`arr + i`)로, 연결 리스트는 `node->next`로 순회 방식이 완전히 달랐지만, C++ iterator는 vector/list/deque/set/map 모두에서 동일한 `begin()`/`end()`/`*it`/`++it` 문법을 재사용한다는 점이 핵심 차이로 확인됨. [S1]
|
||||
- **stack/queue는 iterator를 지원하지 않음**: vector/list/deque/map/set과 달리, 접근 지점이 의도적으로 제한된 stack과 queue는 iterator 자체를 지원하지 않는다는 점이 명시적으로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
vector에서 특정 값("BMW")을 가진 요소를 순회 중에 삭제하는 예제가 iterator가 for-each보다 유리한 실전 사례로 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Iterator-based erase during traversal — impossible with a simple for-each (C++):
|
||||
```cpp
|
||||
#include <vector>
|
||||
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
|
||||
for (auto it = cars.begin(); it != cars.end(); ) {
|
||||
if (*it == "BMW") {
|
||||
it = cars.erase(it); // erase returns the next valid iterator
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Maps]], [[CPP Algorithms]], [[CPP Pointers]], [[CPP Auto]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Algorithms 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Iterators — https://www.w3schools.com/cpp/cpp_iterators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Iterators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: cpp-list
|
||||
title: "C++ List"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::list", "doubly linked list C++", "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", "stl", "list"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_list.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP List]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`list` is the STL container that most directly replaces what C programmers had to hand-build with `struct Node { int data; Node* next; }` — a linked list that grows anywhere and adds/removes at both ends cheaply — but in exchange for that flexibility it gives up random-access indexing entirely (no `list[i]`), so choosing between vector and list is choosing between C-array-like index speed versus C-linked-list-like two-ended growth, expressed here as a one-line design decision instead of a whole custom data structure. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`list<type> name`** — declared like a vector, e.g. `list<string> cars;`, requires `<list>`. [S1]
|
||||
- **No index access** — unlike vector, elements cannot be retrieved by `[i]` or `.at(i)`; only `.front()` and `.back()` are available. [S1]
|
||||
- **Both-ends growth** — `.push_front()` / `.push_back()` add at the beginning/end; `.pop_front()` / `.pop_back()` remove from the beginning/end — vectors only optimize the "back" side. [S1]
|
||||
- **`.front()` / `.back()` are also mutable** — assigning to `cars.front() = "Opel"` changes the first element directly, since there's no index-based assignment. [S1]
|
||||
- **Looping restriction** — a traditional indexed `for` loop combined with `.size()` does NOT work for lists (no `cars[i]`); only a for-each loop (or, later, an iterator) can traverse a list. [S1]
|
||||
- **`.size()` / `.empty()`** — same semantics as vector. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration with initial values: `list<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};`. [S1]
|
||||
- Add: `cars.push_front("Tesla"); cars.push_back("VW");`. [S1]
|
||||
- Remove: `cars.pop_front(); cars.pop_back();`. [S1]
|
||||
- The page explicitly shows the broken indexed-loop attempt (`for (int i = 0; i < cars.size(); i++) { cout << cars[i]; }`) as something that will NOT compile, then gives the working for-each replacement. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **인덱스 접근 자체가 존재하지 않음**: vector는 배열처럼 인덱스 접근이 가능했지만, list는 순차 연결 구조이기 때문에 인덱스 접근 자체가 언어 차원에서 불가능하다는 점이 이번 챕터에서 vector와의 핵심 차이로 명시됨. [S1]
|
||||
- **양쪽 끝 삽입/삭제가 대칭적으로 지원됨**: vector는 뒤쪽(push_back/pop_back)에만 최적화되어 있었지만, list는 앞/뒤 양쪽 모두 push_front/pop_front, push_back/pop_back으로 대칭적으로 지원한다는 점이 vector와 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 이름 리스트의 양 끝에 원소를 추가/삭제하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
List-specific operations unavailable on vector — both-ends push/pop (C++):
|
||||
```cpp
|
||||
#include <list>
|
||||
list<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
|
||||
cars.push_front("Tesla"); // add at beginning
|
||||
cars.push_back("VW"); // add at end
|
||||
cars.pop_front(); // remove from beginning
|
||||
cars.pop_back(); // remove from end
|
||||
|
||||
// No index access — must use for-each:
|
||||
for (string car : cars) {
|
||||
cout << car << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Vectors]], [[CPP Stacks]], [[CPP Data Structures]], [[C Pointers]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Stacks 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ List — https://www.w3schools.com/cpp/cpp_list.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ List" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: cpp-maps
|
||||
title: "C++ Maps"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::map", "key-value pairs C++", "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", "stl", "map"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_maps.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Maps]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`map` reuses set's "auto-sort + unique" behavior but shifts what must be unique from the ELEMENT itself to just the KEY, letting VALUES repeat freely — and it overloads `[]` with a dual meaning no other container has: `people["Jenny"] = 22;` on a key that doesn't exist SILENTLY CREATES it (unlike vector's `[]`, which never grows the container), meaning map's `[]` is simultaneously a read, a write, AND an insert operator depending on context, a three-way overload that requires `.at()` or `.count()` when you need to tell those cases apart. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`map<keytype, valuetype> name`** — two type parameters instead of one, e.g. `map<string, int> people;`; requires `<map>`. [S1]
|
||||
- **Unique keys, non-unique values** — like set's uniqueness rule but applied only to the key half of each pair; values can repeat freely. [S1]
|
||||
- **Auto-sorted by key** — same ascending-order-by-default behavior as set, reversible with `greater<type>` as the third template parameter. [S1]
|
||||
- **`[]` as read/write/insert** — `people["John"]` reads the value for an existing key, `people["John"] = 50;` overwrites it, and `people["Jenny"] = 22;` on a NEW key silently inserts it — three distinct behaviors under one syntax. [S1]
|
||||
- **`.at()`** — safer read/write alternative that throws if the key doesn't exist, unlike `[]` which would silently create a new entry instead of erroring. [S1]
|
||||
- **`.insert({key, value})`** — explicit alternative to `[]` for adding; if the key already exists, the insert is silently ignored (first value wins, matching set's duplicate-drop behavior). [S1]
|
||||
- **`.count(key)`** — returns 1/0 to check key existence without risking an accidental insert. [S1]
|
||||
- **Looping requires `auto` + `.first`/`.second`** — `for (auto person : people) { cout << person.first << person.second; }`, since each element is a key-value pair, not a single value. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration: `map<string, int> people = { {"John", 32}, {"Adele", 45}, {"Bo", 29} };`. [S1]
|
||||
- Access: `people["John"]`, `people.at("Adele")`; `.at()` throws for a missing key (`people.at("Jenny")` errors), while `people["Jenny"]` would just create it. [S1]
|
||||
- Duplicate-key insert is ignored: `people.insert({"Jenny", 22}); people.insert({"Jenny", 30});` keeps only 22. [S1]
|
||||
- Existence check without mutation: `people.count("John")` returns 1. [S1]
|
||||
- Loop pattern: `for (auto person : people) { cout << person.first << " is: " << person.second << "\n"; }` — output is sorted by key (Adele, Bo, John), not insertion order. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **[] 연산자가 vector와 다르게 동작함**: vector의 []는 존재하는 인덱스만 읽고 범위를 벗어나면 정의되지 않은 동작이었지만, map의 []는 존재하지 않는 키에 값을 대입하면 조용히 새 요소를 생성한다는 점이 vector와의 핵심 차이로 확인됨. [S1]
|
||||
- **set의 고유성 규칙이 키에만 적용되도록 완화됨**: set은 요소 전체가 고유해야 했지만, map은 키만 고유하면 되고 값은 자유롭게 중복될 수 있다는 점이 set 규칙의 부분적 완화로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
사람 이름과 나이를 저장하는 map에서 값을 읽고, 수정하고, .count()로 존재 여부를 확인하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Map's `[]` reads, writes, AND silently inserts depending on context (C++):
|
||||
```cpp
|
||||
#include <map>
|
||||
map<string, int> people = { {"John", 32}, {"Adele", 45}, {"Bo", 29} };
|
||||
|
||||
people["Jenny"] = 22; // key doesn't exist -> silently inserted
|
||||
cout << people.at("Adele"); // safe read, throws if missing
|
||||
cout << people.count("John"); // 1 if exists, 0 if not -- no risk of insert
|
||||
|
||||
for (auto person : people) { // sorted by key: Adele, Bo, Jenny, John
|
||||
cout << person.first << " is: " << person.second << "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Sets]], [[CPP Iterators]], [[CPP Data Structures]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Iterators 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Maps — https://www.w3schools.com/cpp/cpp_maps.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Maps" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-math
|
||||
title: "C++ Math"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["max min functions", "cmath library", "C++ 수학 함수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "math", "cmath"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_math.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Math]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`max()` and `min()` are used with NO header include shown in the source's own examples, while `sqrt()`, `round()`, and `log()` explicitly require `#include <cmath>` — a distinction the source draws implicitly through its section structure (max/min presented first, standalone; `<cmath>` functions grouped separately under their own header requirement), suggesting C++ split basic comparison-style math from the broader mathematical function library across different availability boundaries. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`max(x, y)`** — returns the higher of two values. [S1]
|
||||
- **`min(x, y)`** — returns the lower of two values. [S1]
|
||||
- **`<cmath>` header** — required for broader math functions: `sqrt()` (square root), `round()` (rounds a number), `log()` (natural logarithm), and more. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic max/min: `cout << max(5, 10); cout << min(5, 10);`. [S1]
|
||||
- cmath-based functions: `#include <cmath> cout << sqrt(64); cout << round(2.6); cout << log(2);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — sqrt/round/log 등 cmath 함수들이 이후 챕터의 다양한 계산 로직에서 재사용될 수 있는 기본 도구다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Using cmath library functions for square root, rounding, and logarithm (C++):
|
||||
```cpp
|
||||
#include <cmath>
|
||||
cout << sqrt(64); // 8
|
||||
cout << round(2.6); // 3
|
||||
cout << log(2); // 0.693147...
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Numbers]], [[CPP Booleans]], [[C Math]]
|
||||
- **참조 맥락:** 수학 섹션 유일 챕터 — 불리언(Booleans) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Math — https://www.w3schools.com/cpp/cpp_math.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Math" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-memory-management
|
||||
title: "C++ Memory Management"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["memory management overview", "when to manage memory", "C++ 메모리 관리"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "memory-management"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_memory_management.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Memory Management]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source draws a sharp line between two memory scenarios rather than presenting C++ as "always manual" — normal variables (`int x = 10;`) are ALWAYS handled automatically by the compiler, and manual management only becomes YOUR job when you need to create memory WHILE THE PROGRAM RUNS (e.g. based on user input) — meaning the choice to manage memory manually is triggered by a specific need (unknown-size, runtime-determined data), not a default C++ obligation for every variable. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Automatic memory for normal variables** — `int myNumber = 10;` is fully handled by the compiler; no manual management needed. [S1]
|
||||
- **`sizeof`** — checks how much memory a type uses, same as C. [S1]
|
||||
- **Manual management triggers** — needed specifically when creating memory AT RUNTIME (e.g. size depends on user input), not for ordinary declared variables. [S1]
|
||||
- **Risk of mismanagement** — using too much memory, or forgetting to release it, causes slow performance or crashes. [S1]
|
||||
- **Preview of the tool** — pointers let you access/change memory directly; the NEXT chapter introduces `new` (create) and `delete` (free) for manual memory. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Confirming basic type sizes via sizeof: `int myInt; float myFloat; double myDouble; char myChar; cout << sizeof(myInt); // 4 cout << sizeof(myDouble); // 8`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **수동 메모리 관리는 특정 상황에서만 필요**: 일반 변수는 항상 컴파일러가 자동으로 처리하며, 사용자 입력 기반 등 실행 중 크기가 결정되는 메모리를 만들 때만 수동 관리가 필요하다는 점이 명확히 구분됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터가 개관하는 자동/수동 메모리 관리의 경계가 다음 챕터(new/delete)의 구체적 예제로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Checking the actual byte sizes of C++'s basic types with sizeof (C++):
|
||||
```cpp
|
||||
int myInt;
|
||||
float myFloat;
|
||||
double myDouble;
|
||||
char myChar;
|
||||
cout << sizeof(myInt) << "\n"; // 4 bytes
|
||||
cout << sizeof(myDouble) << "\n"; // 8 bytes
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Pointers Modify]], [[CPP Memory Management New]], [[C Memory Management]]
|
||||
- **참조 맥락:** 메모리 관리 개관 — new/delete(Memory Management New) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Memory Management — https://www.w3schools.com/cpp/cpp_memory_management.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Memory Management" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: cpp-memory-management-new
|
||||
title: "C++ new and delete"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["new keyword", "delete keyword", "new[] delete[]", "dynamic arrays", "C++ new와 delete"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "memory-management", "new", "delete"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_memory_management_new.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP new and delete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++'s `new`/`delete` pair REPLACES C's `malloc()`/`free()` pair entirely, but with a critical syntactic split C never had: single values use plain `new`/`delete`, while ARRAYS require the bracketed `new[]`/`delete[]` forms specifically — mismatching them (using plain `delete` on an array allocated with `new[]`) is exactly the kind of subtle bug this language-level distinction exists to prevent, unlike C where `malloc()`/`free()` work identically for both single values and arrays. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`new type`** — allocates memory for ONE value of `type`, returning a pointer to it. [S1]
|
||||
- **`delete pointer;`** — releases memory allocated with plain `new`. [S1]
|
||||
- **`new type[count]`** — allocates memory for an ARRAY of `count` elements; REQUIRES the bracketed form, not plain `new`. [S1]
|
||||
- **`delete[] pointer;`** — releases memory allocated with `new[]`; must match the array form, not plain `delete`. [S1]
|
||||
- **Memory leak** — forgetting `delete` doesn't crash the program immediately, but memory usage grows over time, eventually slowing or crashing it. [S1]
|
||||
- **When to use `new`** — only when the required memory amount is unknown in advance (e.g. depends on user input) or full manual control is needed; ordinary variables never need it. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic single-value allocation: `int* ptr = new int; *ptr = 35; cout << *ptr; delete ptr;`. [S1]
|
||||
- Dynamic array allocation sized by runtime user input: `int numGuests; cin >> numGuests; string* guests = new string[numGuests]; for (int i = 0; i < numGuests; i++) { getline(cin, guests[i]); } delete[] guests;` — array size determined entirely at runtime, impossible with a fixed-size array. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **배열용 new[]/delete[]와 단일 값용 new/delete는 반드시 짝을 맞춰야 함**: C의 malloc()/free()는 단일 값과 배열 모두에 동일하게 쓰이지만, C++는 배열엔 반드시 new[]/delete[]를, 단일 값엔 new/delete를 써야 한다는 점이 명시적으로 구분됨 — 짝을 맞추지 않으면 문제가 생길 수 있음이 암시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
호텔 투숙객 수를 사용자에게 입력받아 그만큼의 이름을 저장할 동적 배열을 만드는 예제가 원문에서 직접 실전 활용 사례로 제시됨(배열 크기를 실행 중에 결정해야 하는 상황). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A dynamic array sized at runtime by user input, freed with the matching delete[] form (C++):
|
||||
```cpp
|
||||
int numGuests;
|
||||
cout << "How many guests? ";
|
||||
cin >> numGuests;
|
||||
string* guests = new string[numGuests];
|
||||
cin.ignore();
|
||||
for (int i = 0; i < numGuests; i++) {
|
||||
getline(cin, guests[i]);
|
||||
}
|
||||
delete[] guests; // must match new[] with delete[]
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Memory Management]], [[CPP Functions]], [[C Memory Allocate]]
|
||||
- **참조 맥락:** 참조·포인터·메모리 섹션 마지막 — 함수(Functions) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ new and delete — https://www.w3schools.com/cpp/cpp_memory_management_new.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ new and delete" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: cpp-namespaces
|
||||
title: "C++ Namespaces"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["namespace keyword", "std namespace", "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", "namespaces"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_namespaces.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Namespaces]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter finally reveals WHAT `std` actually is, after every prior chapter used `using namespace std;` without explanation — `cout`, `cin`, and `endl` all belong to a namespace literally named `std` (for "standard"), meaning the tutorial's own beginner convention of writing `using namespace std;` at the top of every program has been silently invoking the SAME feature this chapter formally introduces, retroactively explaining dozens of earlier code examples. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Namespace** — groups related code under a name to avoid naming conflicts, like a "folder" that lets the same variable name exist in two places without clashing. [S1]
|
||||
- **`namespace Name { ... }`** — declares a namespace; members accessed via `Name::member`. [S1]
|
||||
- **`using namespace Name;`** — imports a namespace's members so they can be used WITHOUT the `Name::` prefix — convenient but risks name conflicts in large programs. [S1]
|
||||
- **`std`** — the Standard Library's namespace; `cout`, `cin`, `endl` all belong to it, which is why `std::cout` is the "full" form and `using namespace std;` is what makes plain `cout` work. [S1]
|
||||
- **Scale-dependent recommendation** — `using namespace std;` is fine for small/learning programs; explicit `std::` prefixes are safer in large projects to avoid conflicts between libraries. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic custom namespace: `namespace MyNamespace { int x = 42; } cout << MyNamespace::x;`. [S1]
|
||||
- Importing a namespace to drop the prefix: `using namespace MyNamespace; cout << x; // no need for MyNamespace::x`. [S1]
|
||||
- The std namespace explained retroactively: `std::cout << "Hello World!\n";` (without `using namespace std;`) versus `using namespace std; cout << "Hello World!\n";` (with it). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **std가 실제로는 네임스페이스였음이 뒤늦게 공개됨**: 이전의 모든 챕터에서 설명 없이 써온 using namespace std;가 사실 이 챕터에서 정식으로 소개하는 네임스페이스 기능을 그대로 사용한 것이었다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대규모 프로젝트에서는 using namespace std; 대신 std::를 명시적으로 쓰는 것이 라이브러리 간 이름 충돌을 방지하는 실전 관행으로 권장됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A custom namespace, accessed both explicitly and via using (C++):
|
||||
```cpp
|
||||
namespace MyNamespace {
|
||||
int x = 42;
|
||||
}
|
||||
int main() {
|
||||
cout << MyNamespace::x; // explicit form
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Templates]], [[CPP Syntax]], [[CPP Strings Namespace]], [[CPP Scope]]
|
||||
- **참조 맥락:** 네임스페이스 — 변수 스코프(Scope) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Namespaces — https://www.w3schools.com/cpp/cpp_namespaces.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Namespaces" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: cpp-new-lines
|
||||
title: "C++ New Lines"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["\\n vs endl", "escape sequence", "C++ 줄바꿈"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "newline", "endl"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_new_lines.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP New Lines]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ offers TWO distinct ways to create a new line — the escape sequence `\n` and the `endl` manipulator — and the source explicitly states both do the same visible job but `\n` is "most used," meaning `endl` is a genuine C++-specific alternative to `\n` that C's `printf()` never had, since manipulators (objects that modify stream behavior via `<<`) are a C++-only I/O stream concept. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`\n`** — the escape sequence for a new line, same concept as in C; can be embedded inside a string OR appended via a separate `<<` operator. [S1]
|
||||
- **`endl`** — a C++-specific stream MANIPULATOR that also breaks lines, inserted via `<<` like a regular value. [S1]
|
||||
- **Doubled `\n` produces a blank line** — same behavior as C. [S1]
|
||||
- **`\n` is more commonly used** than `endl`, despite both being valid. [S1]
|
||||
- **Other escape sequences** — `\t` (tab), `\\` (backslash), `\"` (double quote) — same set as C. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Newline embedded in a string: `cout << "Hello World! \n"; cout << "I am learning C++";`. [S1]
|
||||
- Newline appended via a separate `<<`: `cout << "Hello World!" << "\n";`. [S1]
|
||||
- Blank line via doubled `\n`: `cout << "Hello World!" << "\n\n";`. [S1]
|
||||
- Using the `endl` manipulator instead: `cout << "Hello World!" << endl; cout << "I am learning C++";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **endl은 C++ 고유의 스트림 조작자**: \n과 같은 결과를 내지만, endl은 <<로 삽입되는 스트림 매니퓰레이터라는 C++만의 개념으로, C의 printf()에는 대응 개념이 없다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — \n과 endl 중 \n이 더 널리 쓰인다는 점이 실전 코드 스타일 선택의 기준으로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Using the endl manipulator as an alternative to \n (C++):
|
||||
```cpp
|
||||
cout << "Hello World!" << endl;
|
||||
cout << "I am learning C++";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Output Numbers]], [[CPP Variables]], [[C Newline]]
|
||||
- **참조 맥락:** Basics 섹션 마지막 — 변수(Variables) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ New Lines — https://www.w3schools.com/cpp/cpp_new_lines.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ New Lines" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: cpp-oop
|
||||
title: "C++ OOP"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["object-oriented programming", "DRY principle", "procedural vs OOP", "C++ 객체지향 프로그래밍"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "oop"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_oop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C++ OOP]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The single-sentence distinction the source draws between procedural and object-oriented programming is organizational, not functional — procedural code is "organized around FUNCTIONS," OOP code is "organized around OBJECTS" that BUNDLE data and functions together — meaning the shift to OOP throughout this section of the tutorial isn't introducing new capabilities C++ lacked before, but reorganizing the SAME capabilities (variables, functions) around a different unit of grouping. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **OOP (Object-Oriented Programming)** — organizing code around "objects" that hold both data and functions operating on that data. [S1]
|
||||
- **Class vs. object** — a class defines what an object should look like (a template); an object is created FROM a class and inherits its variables/functions. [S1]
|
||||
- **DRY principle** — "Don't Repeat Yourself"; move repeated code into functions or classes and reuse it. [S1]
|
||||
- **OOP advantages** — clearer program structure, easier maintenance/reuse/debugging, DRY-friendly, enables building full reusable applications faster. [S1]
|
||||
- **Procedural vs. OOP** — procedural organizes code around FUNCTIONS operating on data; OOP organizes code around OBJECTS that contain both data and functions together. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The Class → Objects mapping example: Fruit class → Apple/Banana/Mango objects; Car class → Volvo/Audi/Toyota objects. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터의 클래스-객체 개념 개관이 다음 챕터(Classes and Objects)의 실전 코드로 바로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
None — this is a conceptual overview page with no standalone code example.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Functions Lambda]], [[CPP Classes]]
|
||||
- **참조 맥락:** OOP 섹션 첫 챕터 — 클래스와 객체(Classes) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ OOP — https://www.w3schools.com/cpp/cpp_oop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ OOP" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-operators
|
||||
title: "C++ Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["operator categories", "C++ 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ organizes operators into the SAME five categories as C (Arithmetic, Assignment, Comparison, Logical, Bitwise) — but unlike C's equivalent chapter, which explicitly labeled Bitwise as "advanced," C++'s overview lists it as an ordinary fifth category with no such qualifier, suggesting the tutorial treats bitwise operations as standard-tier knowledge rather than a specially-flagged advanced topic. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Operator** — performs an operation on variables and/or values. [S1]
|
||||
- **Five operator categories** — Arithmetic, Assignment, Comparison, Logical, Bitwise. [S1]
|
||||
- **Uniform operand handling** — the same operator works on literal-literal, variable-literal, and variable-variable combinations identically. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Chained addition using literals and variables interchangeably: `int sum1 = 100 + 50; int sum2 = sum1 + 250; int sum3 = sum2 + sum2;` — evaluates to 150, 400, 800. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **비트 연산자가 "고급"으로 별도 표시되지 않음**: C 튜토리얼은 비트 연산자를 명시적으로 "advanced"라고 표시했지만, C++ 튜토리얼의 이 개관 챕터에서는 그런 수식어 없이 다섯 번째 일반 카테고리로만 나열됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터가 제시하는 5개 연산자 분류가 이후 각 챕터 학습의 로드맵 역할을 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The + operator working uniformly across literals, a variable+literal, and variable+variable (C++):
|
||||
```cpp
|
||||
int sum1 = 100 + 50; // 150 (100 + 50)
|
||||
int sum2 = sum1 + 250; // 400 (150 + 250)
|
||||
int sum3 = sum2 + sum2; // 800 (400 + 400)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Data Types RealLife]], [[CPP Operators Arithmetic]]
|
||||
- **참조 맥락:** 연산자 섹션 개관 — 산술 연산자(Operators Arithmetic) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Operators — https://www.w3schools.com/cpp/cpp_operators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-operators-arithmetic
|
||||
title: "C++ Arithmetic Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["integer division", "increment decrement", "C++ 산술 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators", "arithmetic"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators_arithmetic.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Arithmetic Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Integer division truncation carries over from C completely unchanged — `10 / 3` still yields `3` in C++, and the fix is identical too (use `double` operands: `10.0 / 3` gives `3.333...`) — confirming that C++'s arithmetic semantics for the basic numeric types are inherited from C wholesale, not just its syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Seven core arithmetic operators** — `+`, `-`, `*`, `/`, `%` (modulus), `++` (increment), `--` (decrement) — identical set to C. [S1]
|
||||
- **Integer division truncation** — dividing two `int`s always yields an `int`, discarding any decimal remainder; use `double` operands for a decimal result. [S1]
|
||||
- **Increment/decrement round-trip** — incrementing then decrementing the same variable returns it to its original value. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All seven operators demonstrated with chained cout output: `int x = 10; int y = 3; cout << (x + y) << "\n"; // 13 ... cout << (x % y) << "\n"; // 1`. [S1]
|
||||
- Integer vs decimal division contrast: `int x = 10; int y = 3; cout << (x / y); // 3 (integer division)` versus `double a = 10.0; double b = 3.0; cout << (a / b); // 3.333...`. [S1]
|
||||
- Real-life counting example: `int peopleInRoom = 0; peopleInRoom++; peopleInRoom++; peopleInRoom++; // 3 people enter cout << peopleInRoom; // 3` then `peopleInRoom--; // 2`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C와 완전히 동일한 정수 나눗셈 절삭**: int끼리 나누면 소수점이 버려진다는 점과 그 해결책(double 사용)이 C 챕터와 동일하게 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
방에 들어오고 나가는 사람 수를 ++/--로 세는 카운터 예제가 원문에서 직접 실전 활용 사례로 제시됨(C 챕터와 동일한 예제). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Integer division truncates; use double operands for a decimal result (C++):
|
||||
```cpp
|
||||
int x = 10;
|
||||
int y = 3;
|
||||
cout << (x / y); // Integer division, result is 3
|
||||
|
||||
double a = 10.0;
|
||||
double b = 3.0;
|
||||
cout << (a / b); // Decimal division, result is 3.333...
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators]], [[CPP Operators Assignment]], [[C Operators Arithmetic]]
|
||||
- **참조 맥락:** 산술 연산자 — 대입 연산자(Operators Assignment) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Arithmetic Operators — https://www.w3schools.com/cpp/cpp_operators_arithmetic.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arithmetic Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-operators-assignment
|
||||
title: "C++ Assignment Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["compound assignment", "+= -= *=", "C++ 대입 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators", "assignment"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators_assignment.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Assignment Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter explicitly explains WHY these operators are called "compound" — they combine a regular operator (`+`, `-`, `*`, etc.) with the assignment operator (`=`) into ONE single operator (`+=` = `+` combined with `=`) — a naming rationale C's equivalent chapter never spelled out, even though the underlying expansion rule (`x OP= y` ≡ `x = x OP y`) is identical between the two languages. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`=`** — basic assignment. [S1]
|
||||
- **Compound assignment operators** — `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `>>=`, `<<=`, each expanding to `x = x <op> value`. [S1]
|
||||
- **"Compound" naming rationale** — explicitly explained as combining a regular operator with `=` into one operator symbol. [S1]
|
||||
- **Purpose** — pure shorthand for readability/brevity, especially when updating the same variable repeatedly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic compound usage: `int x = 10; x += 5; // same as x = x + 5 cout << x; // 15 x *= 2; // same as x = x * 2 cout << x; // 30`. [S1]
|
||||
- Real-life savings tracker: `int savings = 100; savings += 50; cout << "Total savings: " << savings;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 동일한 확장 규칙이 확인되었으나, "compound"라는 명칭의 유래(연산자+대입 결합)를 이 챕터가 더 명시적으로 설명함.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
저축액에 50을 더하는 savings += 50 예제가 원문에서 직접 실전 활용 사례로 제시됨(계좌 잔액 누적 갱신). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Tracking a running total using the compound addition-assignment operator (C++):
|
||||
```cpp
|
||||
int savings = 100;
|
||||
savings += 50; // add 50 to savings
|
||||
cout << "Total savings: " << savings;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators Arithmetic]], [[CPP Operators Comparison]], [[C Operators Assignment]]
|
||||
- **참조 맥락:** 대입 연산자 — 비교 연산자(Operators Comparison) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Assignment Operators — https://www.w3schools.com/cpp/cpp_operators_assignment.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Assignment Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: cpp-operators-comparison
|
||||
title: "C++ Comparison Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["== != > <", "boolean 1 or 0", "C++ 비교 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators", "comparison"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators_comparison.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Comparison Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Even though C++ has a genuine `bool` type (unlike C, which needed `<stdbool.h>`), comparison operators STILL return the SAME 1/0 integer convention as C, not a distinct boolean-labeled value — meaning `cout << (x > y)` prints `1`, not `true`, showing that C++'s richer type system didn't change the underlying comparison-result representation inherited from C. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Six comparison operators** — `==`, `!=`, `>`, `<`, `>=`, `<=` — identical set to C. [S1]
|
||||
- **Integer return value** — every comparison returns `1` (true) or `0` (false), printable directly via `cout <<` with no format specifier. [S1]
|
||||
- **Practical decision-making use** — comparisons drive if/else logic (covered in upcoming chapters). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic greater-than check: `int x = 5; int y = 3; cout << (x > y); // returns 1 (true)`. [S1]
|
||||
- Voting age eligibility check: `int age = 18; cout << (age >= 18) << "\n"; // 1 (true) cout << (age < 18) << "\n"; // 0 (false)`. [S1]
|
||||
- Password length check: `int passwordLength = 5; cout << (passwordLength >= 8) << "\n"; // 0 (false), too short`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **bool 타입이 있어도 비교 결과는 여전히 1/0 정수**: C++가 진짜 bool 타입을 갖췄음에도 비교 연산 결과는 true/false 문자열이 아니라 여전히 1/0 정수로 출력된다는 점이 확인됨 — C의 관례가 그대로 이어짐. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
투표 가능 연령 확인(age >= 18)과 비밀번호 길이 확인(passwordLength >= 8)이 원문에서 직접 실전 활용 사례로 제시됨(C 챕터와 동일한 예제). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Comparison operators still returning plain integers (1 or 0), despite C++ having a genuine bool type (C++):
|
||||
```cpp
|
||||
int age = 18;
|
||||
cout << (age >= 18) << "\n"; // 1 (true), old enough to vote
|
||||
cout << (age < 18) << "\n"; // 0 (false)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators Assignment]], [[CPP Operators Logical]], [[CPP Data Types Bool]]
|
||||
- **참조 맥락:** 비교 연산자 — 논리 연산자(Operators Logical) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Comparison Operators — https://www.w3schools.com/cpp/cpp_operators_comparison.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Comparison Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-operators-logical
|
||||
title: "C++ Logical Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["&& || !", "logical AND OR NOT", "C++ 논리 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators", "logical"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators_logical.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Logical Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source labels these results "true (1) or false (0)" in the SAME breath, explicitly pairing the boolean word with its integer representation — a small but telling detail showing C++ treats `true`/`false` as just readable NAMES for the underlying 1/0 values rather than a genuinely distinct data representation, consistent with the Comparison Operators chapter's finding. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`&&` (AND)** — returns true only if BOTH statements are true. [S1]
|
||||
- **`||` (OR)** — returns true if AT LEAST ONE statement is true. [S1]
|
||||
- **`!` (NOT)** — reverses the result. [S1]
|
||||
- **True(1)/False(0) duality** — the source explicitly writes results as "true (1) or false (0)," reinforcing that boolean values ARE their integer representation, not a separate concept. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The three operators listed with example expressions: `x < 5 && x < 10` (AND), `x < 5 || x < 4` (OR), `!(x < 5 && x < 10)` (NOT). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터가 소개하는 세 논리 연산자가 이후 조건문 내 논리 연산(Conditions Logical) 챕터의 실전 응용으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combining two conditions with logical AND (C++):
|
||||
```cpp
|
||||
int x = 4;
|
||||
cout << (x < 5 && x > 2); // 1 (true) — both conditions hold
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators Comparison]], [[CPP Operators Precedence]], [[CPP Conditions Logical]]
|
||||
- **참조 맥락:** 논리 연산자 — 연산자 우선순위(Operators Precedence) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Logical Operators — https://www.w3schools.com/cpp/cpp_operators_logical.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Logical Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: cpp-operators-precedence
|
||||
title: "C++ Operator Precedence"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["order of operations", "parentheses precedence", "C++ 연산자 우선순위"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "operators", "precedence"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_operators_precedence.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Operator Precedence]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The precedence hierarchy and left-to-right associativity rule are IDENTICAL to C's version, right down to the exact same worked examples (`2 + 3 * 4` = 14, `10 - 2 + 5` = 13) — meaning C++ programmers can reuse C's mental model for expression evaluation without any adjustment, since neither the ranking of operator tiers nor the tie-breaking rule for same-tier operators changed. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Precedence hierarchy (highest to lowest)** — `()` → `*`/`/`/`%` → `+`/`-` → comparison (`>`,`<`,`>=`,`<=`) → equality (`==`,`!=`) → `&&` → `||` → `=`. [S1]
|
||||
- **Multiplication before addition** — `2 + 3 * 4` evaluates `*` first, giving `14`. [S1]
|
||||
- **Parentheses override precedence** — `(2 + 3) * 4` forces addition first, giving `20`. [S1]
|
||||
- **Left-to-right associativity for same-tier operators** — `10 - 2 + 5` evaluates as `(10 - 2) + 5 = 13`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Precedence demonstration: `int result1 = 2 + 3 * 4; // 14 int result2 = (2 + 3) * 4; // 20`. [S1]
|
||||
- Left-to-right associativity demonstration: `int result1 = 10 - 2 + 5; // 13 int result2 = 10 - (2 + 5); // 3`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 우선순위표·예제가 완전히 동일함이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 계산 순서가 애매할 때 항상 괄호를 사용하라는 권고가 C 챕터와 동일하게 강조된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Same-precedence operators evaluate strictly left to right unless parentheses override it (C++):
|
||||
```cpp
|
||||
int result1 = 10 - 2 + 5; // (10 - 2) + 5 = 13
|
||||
int result2 = 10 - (2 + 5); // 10 - 7 = 3
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators Logical]], [[CPP Strings]], [[C Operators Precedence]]
|
||||
- **참조 맥락:** 연산자 섹션 마지막 — 문자열(Strings) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Operator Precedence — https://www.w3schools.com/cpp/cpp_operators_precedence.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Operator Precedence" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-output
|
||||
title: "C++ Output (Print Text)"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["cout insertion operator", "C++ 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "output", "cout"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_output.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Output (Print Text)]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`cout` never inserts a newline automatically — exactly the same behavior as C's `printf()` — meaning C++'s I/O model, despite replacing `printf()` with an object-and-operator syntax (`cout <<`), preserves the identical "no automatic line breaks" limitation, so multiple `cout` calls still concatenate onto one line unless the programmer explicitly adds a newline character. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`cout` + `<<`** — the object and insertion operator used to print text; text must be wrapped in double quotes. [S1]
|
||||
- **No automatic newline** — multiple `cout` statements concatenate output onto ONE line, just like C's `printf()`. [S1]
|
||||
- **Multiple `cout` calls allowed** — as many as needed in one program. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic print: `cout << "Hello World!";`. [S1]
|
||||
- Newline-less concatenation across two calls: `cout << "Hello World!"; cout << "I am learning C++"; // both render on one line`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **cout도 printf()처럼 줄바꿈을 자동 삽입하지 않음**: 여러 cout 호출 결과가 모두 한 줄에 이어져 출력된다는 점이 C의 printf() 동작과 동일함이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터(New Lines)에서 \n과 endl로 줄바꿈을 명시적으로 추가하는 방법으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two cout calls concatenating onto one line with no automatic newline (C++):
|
||||
```cpp
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main() {
|
||||
cout << "Hello World!";
|
||||
cout << "I am learning C++";
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Comments]], [[CPP Output Numbers]], [[CPP New Lines]]
|
||||
- **참조 맥락:** 텍스트 출력 — 숫자 출력(Output Numbers) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Output (Print Text) — https://www.w3schools.com/cpp/cpp_output.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Output (Print Text)" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: cpp-output-numbers
|
||||
title: "C++ Output Numbers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["cout math expressions", "C++ 숫자 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "output", "numbers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_output_numbers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Output Numbers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`cout <<` accepts a raw MATHEMATICAL EXPRESSION directly (`cout << 3 + 3;`), not just a pre-computed variable or literal — meaning `<<`'s right-hand side is evaluated as a genuine expression before printing, unlike a naive assumption that only simple values can follow the insertion operator. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **No quotes for numbers** — unlike text, numeric values are NOT wrapped in double quotes when printed with `cout`. [S1]
|
||||
- **Inline expression evaluation** — `cout << 3 + 3;` computes the sum THEN prints the result (6), not the literal text "3 + 3". [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Printing a bare number: `cout << 3;`. [S1]
|
||||
- Printing the result of addition: `cout << 3 + 3; // 6`. [S1]
|
||||
- Printing the result of multiplication: `cout << 2 * 5; // 10`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — cout에 수식을 직접 넣어 계산 결과를 출력하는 패턴이 이후 산술 연산자(Operators Arithmetic) 챕터의 기초가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Printing the result of an inline arithmetic expression (C++):
|
||||
```cpp
|
||||
cout << 3 + 3; // Outputs 6, not "3 + 3"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Output]], [[CPP New Lines]]
|
||||
- **참조 맥락:** 숫자 출력 — 줄바꿈(New Lines) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Output Numbers — https://www.w3schools.com/cpp/cpp_output_numbers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Output Numbers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: cpp-pointers
|
||||
title: "C++ Pointers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pointer declaration", "preferred syntax style", "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", "pointers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_pointers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Pointers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source explicitly ranks THREE valid pointer-declaration spacing styles (`string* mystring;`, `string *mystring;`, `string * mystring;`) and states the FIRST is "preferred" — a stylistic recommendation C's Pointers chapter never made, meaning C++ style guides have converged on attaching `*` to the TYPE rather than the variable name, even though all three compile identically. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Pointer** — a variable that stores another variable's memory address as its value. [S1]
|
||||
- **Type-matched declaration** — a pointer's type must match the type it points to (`string* ptr` for a `string`). [S1]
|
||||
- **Preferred spacing style** — `string* mystring;` (asterisk attached to the type) is explicitly called out as preferred over `string *mystring;` or `string * mystring;`, though all three are equivalent. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Creating a pointer and reading the address it stores: `string food = "Pizza"; string* ptr = &food; cout << ptr; // same address as &food`. [S1]
|
||||
- Three equivalent but stylistically ranked declarations: `string* mystring; // Preferred string *mystring; string * mystring;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **선호되는 포인터 선언 스타일이 명시됨**: C 챕터에는 없던 스타일 권고로, string* ptr처럼 별표를 타입에 붙이는 방식이 선호된다는 점이 명확히 제시됨(세 가지 모두 동일하게 작동하지만). [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 별표를 타입에 붙이는 스타일이 실전 C++ 코드 컨벤션에서 권장되는 표기법이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Creating a pointer using the preferred declaration style (C++):
|
||||
```cpp
|
||||
string food = "Pizza";
|
||||
string* ptr = &food; // Preferred style: * attached to the type
|
||||
cout << ptr << "\n"; // same address as &food
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP References Memory]], [[CPP Pointers Dereference]], [[C Pointers]]
|
||||
- **참조 맥락:** 포인터 기초 — 역참조(Pointers Dereference) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Pointers — https://www.w3schools.com/cpp/cpp_pointers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Pointers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-pointers-dereference
|
||||
title: "C++ Dereference"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["dereference operator", "* dual meaning", "C++ 역참조"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "pointers", "dereference"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_pointers_dereference.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Dereference]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `*` symbol does two OPPOSITE jobs depending on where it appears — identical to C's pointer chapter — in a declaration (`string* ptr`) it CREATES a pointer, but everywhere else (`*ptr`) it DEREFERENCES one to retrieve the pointed-to value, confirming C++ inherited this exact dual-meaning confusion point from C without modification. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`*` in declaration vs. elsewhere** — `string* ptr;` creates a pointer variable; `*ptr` (outside declaration) dereferences it to get the pointed-to value. [S1]
|
||||
- **Reference (`&`) vs. dereference (`*`)** — `ptr` alone gives the address; `*ptr` gives the value. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Reference vs. dereference side by side: `string food = "Pizza"; string* ptr = &food; cout << ptr; // 0x6dfed4 (address) cout << *ptr; // Pizza (value)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **`*`의 이중 의미가 C와 동일하게 확인됨**: 선언에서는 포인터를 만들고, 선언이 아닌 곳에서는 역참조 연산자로 동작한다는 혼동 요소가 C 챕터와 완전히 동일함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 역참조 연산자를 이용해 포인터가 가리키는 변수의 값을 직접 변경하는 것이 다음 챕터(Modify Pointers)에서 실전 활용으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reference vs. dereference on the same pointer (C++):
|
||||
```cpp
|
||||
string food = "Pizza";
|
||||
string* ptr = &food;
|
||||
cout << ptr << "\n"; // Reference: memory address of food
|
||||
cout << *ptr << "\n"; // Dereference: value of food (Pizza)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Pointers]], [[CPP Pointers Modify]], [[C Pointers]]
|
||||
- **참조 맥락:** 역참조 — 포인터 값 수정(Pointers Modify) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Dereference — https://www.w3schools.com/cpp/cpp_pointers_dereference.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Dereference" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-pointers-modify
|
||||
title: "C++ Modify Pointers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["mutating through a pointer", "C++ 포인터 값 수정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "pointers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_pointers_modify.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Modify Pointers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Assigning `*ptr = "Hamburger";` doesn't change what the POINTER points to — it changes the VALUE at the address the pointer already points to — so the original variable (`food`) changes too, since `ptr` and `food` still reference the exact same memory location; this is the mechanical proof behind why passing a pointer into a function lets that function permanently alter the caller's data. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`*ptr = newValue;`** — writes a new value AT the memory address the pointer references, which is the SAME memory the original variable occupies. [S1]
|
||||
- **Original variable changes too** — because `ptr` and the original variable share one memory location, mutating through the pointer is indistinguishable from mutating the variable directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full mutation-through-pointer sequence: `string food = "Pizza"; string* ptr = &food; cout << *ptr; // Pizza *ptr = "Hamburger"; cout << *ptr; // Hamburger cout << food; // Hamburger — the original changed too`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 포인터를 통해 원본 변수의 값을 변경하는 이 메커니즘이 함수에 포인터를 전달해 원본 데이터를 수정하는 실전 패턴(Function Pointer/Reference 챕터)의 근거가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mutating a value through a pointer changes the original variable (C++):
|
||||
```cpp
|
||||
string food = "Pizza";
|
||||
string* ptr = &food;
|
||||
*ptr = "Hamburger"; // Change the value at the pointed-to address
|
||||
cout << food; // Outputs "Hamburger" — the original variable changed
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Pointers Dereference]], [[CPP Memory Management]], [[C Pointers]]
|
||||
- **참조 맥락:** 포인터 값 수정 — 메모리 관리(Memory Management) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Modify Pointers — https://www.w3schools.com/cpp/cpp_pointers_modify.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Modify Pointers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: cpp-polymorphism
|
||||
title: "C++ Polymorphism"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["method overriding", "many forms", "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", "polymorphism"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_polymorphism.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Polymorphism]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Polymorphism is explicitly framed as Inheritance's NATURAL EXTENSION, not a separate feature — the source states "Inheritance lets us inherit... Polymorphism uses those methods to perform different tasks," meaning a `Pig` and `Dog` REDEFINING the SAME method name (`animalSound()`) inherited from `Animal` isn't a new syntax to learn, it's simply what happens when a derived class writes its own version of a method it already inherited by name. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Polymorphism** — "many forms"; occurs when related classes (via inheritance) implement the SAME method name differently, so ONE action behaves differently per class. [S1]
|
||||
- **Method overriding** — a derived class REDEFINES a method it inherited from the base class, with the SAME name and signature. [S1]
|
||||
- **Direct extension of inheritance** — polymorphism doesn't add new syntax; it's just what happens when derived classes redefine an inherited method name. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Three classes with the SAME method name, each behaving differently: `class Animal { public: void animalSound() { cout << "The animal makes a sound \n"; } }; class Pig : public Animal { public: void animalSound() { cout << "The pig says: wee wee \n"; } }; class Dog : public Animal { public: void animalSound() { cout << "The dog says: bow wow \n"; } };` — calling `.animalSound()` on each object type produces its own class's version. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Animal 기반 클래스의 animalSound()를 Pig와 Dog가 각각 다르게 재정의하는 예제가 원문에서 직접 실전 활용 사례로 제시됨(동일한 행동, 클래스마다 다른 구현). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The same method name behaving differently across sibling derived classes (C++):
|
||||
```cpp
|
||||
class Animal {
|
||||
public:
|
||||
void animalSound() { cout << "The animal makes a sound \n"; }
|
||||
};
|
||||
class Pig : public Animal {
|
||||
public:
|
||||
void animalSound() { cout << "The pig says: wee wee \n"; }
|
||||
};
|
||||
class Dog : public Animal {
|
||||
public:
|
||||
void animalSound() { cout << "The dog says: bow wow \n"; }
|
||||
};
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Inheritance Multiple]], [[CPP Virtual Functions]]
|
||||
- **참조 맥락:** 다형성 — 가상 함수(Virtual Functions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Polymorphism — https://www.w3schools.com/cpp/cpp_polymorphism.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Polymorphism" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-queues
|
||||
title: "C++ Queues"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::queue", "FIFO", "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", "stl", "queue", "fifo"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_queues.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Queues]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`queue` is stack's mirror image — same restricted-access philosophy (no arbitrary indexing, no brace-list initialization, only `.push()`/`.pop()`), but instead of both ends collapsing onto one "top," a queue keeps `.front()` and `.back()` as two DISTINCT accessible ends, encoding FIFO order (supermarket line: first in line, first served) the same way stack encoded LIFO — the two containers share nearly identical method names (`.push()`, `.pop()`, `.size()`, `.empty()`) but differ in exactly which end `.pop()` removes from, which is the single fact that determines whether a container behaves like a stack or a queue. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **FIFO (First In, First Out)** — the first element added is the first one removed, unlike stack's LIFO. [S1]
|
||||
- **`queue<type> name`** — requires `<queue>`; like stack, CANNOT be initialized with a curly-brace list at declaration — must use `.push()` after declaring. [S1]
|
||||
- **`.push()`** — adds an element to the BACK (end) of the queue. [S1]
|
||||
- **`.front()` / `.back()`** — TWO accessible points (unlike stack's single `.top()`): front is the oldest/first element, back is the newest/last element; both are also assignable. [S1]
|
||||
- **`.pop()`** — removes the FRONT element (the oldest one) — this is the key difference from stack's `.pop()`, which removes from the top/back instead. [S1]
|
||||
- **`.size()` / `.empty()`** — same semantics as stack/list/vector. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration + fill: `queue<string> cars; cars.push("Volvo"); cars.push("BMW"); cars.push("Ford"); cars.push("Mazda");` — resulting order: Volvo(front), BMW, Ford, Mazda(back). [S1]
|
||||
- Access/modify: `cars.front()` → "Volvo", `cars.back()` → "Mazda"; both can be reassigned directly (`cars.front() = "Tesla";`). [S1]
|
||||
- Remove: `cars.pop();` removes Volvo (the front/oldest), making BMW the new front. [S1]
|
||||
- Same brace-initialization restriction as stack is called out explicitly: `queue<string> cars = {"Volvo", ...};` is not allowed. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **stack과 동일한 메서드명, 반대 방향 의미**: stack의 `.pop()`은 top(가장 최근 추가된 요소)을 제거했지만, queue의 `.pop()`은 front(가장 오래된 요소)를 제거한다는 점이 이번 챕터에서 stack과의 핵심 대비로 확인됨 — 메서드 이름은 같아도 동작 방향이 정반대. [S1]
|
||||
- **접근 가능 지점이 하나에서 둘로 늘어남**: stack은 `.top()` 하나만 노출했지만, queue는 `.front()`와 `.back()` 두 지점을 모두 노출한다는 점이 FIFO 구조의 특성상 필요한 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 슈퍼마켓 줄서기에 비유해 FIFO를 설명하고, 자동차 이름을 push()로 채운 뒤 front()/back()으로 확인하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Queue push/front/back/pop — pop always removes from the front, unlike stack (C++):
|
||||
```cpp
|
||||
#include <queue>
|
||||
queue<string> cars;
|
||||
cars.push("Volvo");
|
||||
cars.push("BMW");
|
||||
cars.push("Ford");
|
||||
cars.push("Mazda");
|
||||
|
||||
cout << cars.front(); // "Volvo" (oldest)
|
||||
cout << cars.back(); // "Mazda" (newest)
|
||||
cars.pop(); // removes "Volvo" (the front)
|
||||
cout << cars.front(); // now "BMW"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Stacks]], [[CPP Data Structures]], [[CPP Deque]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Stacks와 짝을 이루는 챕터, 다음은 Deque.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Queues — https://www.w3schools.com/cpp/cpp_queues.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Queues" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-references
|
||||
title: "C++ References"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["reference variable", "alias", "& operator", "C++ 참조"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "references"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_references.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP References]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A reference isn't a COPY or even a pointer to a variable — it's a genuine ALIAS, meaning `food` and `meal` in `string &meal = food;` are two DIFFERENT NAMES for the exact SAME memory location, so changing `meal` changes `food` directly with no dereference operator ever needed — a concept with NO equivalent in C, where the closest thing (a pointer) always requires explicit `*` to reach the value. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Reference variable (`type &alias = original;`)** — an alias for an EXISTING variable, created with the `&` operator at declaration. [S1]
|
||||
- **Same memory location** — the reference and the original variable refer to the identical memory address, not a copy. [S1]
|
||||
- **No dereference needed** — unlike a pointer, using a reference to read or write the value requires no `*`; you just use the reference name directly. [S1]
|
||||
- **Bidirectional change propagation** — changing either the original variable OR the reference changes the other, since they're the same storage. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Creating a reference and reading through both names: `string food = "Pizza"; string &meal = food; cout << food; // Pizza cout << meal; // Pizza`. [S1]
|
||||
- Changing through the reference affects the original: `meal = "Burger"; cout << food; // Burger cout << meal; // Burger`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **참조는 C에 없던 완전히 새로운 개념**: 포인터처럼 별도의 역참조(*) 연산 없이도 원본 변수와 완전히 동일한 메모리를 가리키는 별칭(alias)이라는 점에서, C의 포인터와도 다른 C++ 고유의 개념임이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 참조는 이후 함수 매개변수를 값 복사 없이 전달하는 실전 활용(Function Reference 챕터)의 기초가 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A reference variable acting as a true alias — changing it changes the original directly (C++):
|
||||
```cpp
|
||||
string food = "Pizza"; // food variable
|
||||
string &meal = food; // reference to food (an alias, not a copy)
|
||||
meal = "Burger"; // changes both meal and food
|
||||
cout << food; // Burger
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Enum]], [[CPP References Memory]], [[CPP Pointers]]
|
||||
- **참조 맥락:** 참조·포인터·메모리 섹션 첫 챕터 — 메모리 주소(References Memory) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ References — https://www.w3schools.com/cpp/cpp_references.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ References" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-references-memory
|
||||
title: "C++ Memory Address"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["& dual meaning", "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", "memory", "references", "pointers"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_references_memory.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Memory Address]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `&` operator does TWO completely different jobs depending on where it's used — in a DECLARATION (`string &meal = food;`) it creates a reference/alias, but STANDALONE (`cout << &food;`) it retrieves the memory address — meaning `&`'s dual meaning in C++ directly mirrors the earlier Pointers chapter's warning about `*`'s dual meaning (declaration vs. dereference), giving C++ TWO symbols with context-dependent behavior instead of C's one. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`&` as address-of operator** — outside a declaration, `&variable` retrieves the memory address. [S1]
|
||||
- **`&` as reference-creation operator** — inside a declaration (`type &alias = var;`), `&` creates an alias instead. [S1]
|
||||
- **Hexadecimal address format** — same as C, `0x...`, varies per run/machine. [S1]
|
||||
- **Why it matters** — references AND pointers (covered next) let C++ manipulate memory directly, reducing code and improving performance — explicitly named as one of the things that distinguishes C++ from Python and Java. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Getting a variable's address: `string food = "Pizza"; cout << &food; // Outputs 0x6dfed4`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **&의 이중 의미**: 선언 안에서는 참조(별칭)를 만들지만, 선언 밖에서는 메모리 주소를 가져오는 연산자로 동작한다는 점이 확인되며, 이는 포인터 챕터의 * 이중 의미와 유사한 패턴이다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터의 & 연산자 개념이 다음 챕터(Pointers)에서 실제 포인터 변수 선언의 기초로 그대로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Getting a variable's memory address with the & operator outside a declaration (C++):
|
||||
```cpp
|
||||
string food = "Pizza";
|
||||
cout << &food; // Outputs 0x6dfed4
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP References]], [[CPP Pointers]], [[C Memory Address]]
|
||||
- **참조 맥락:** 메모리 주소 — 포인터(Pointers) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Memory Address — https://www.w3schools.com/cpp/cpp_references_memory.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Memory Address" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: cpp-scope
|
||||
title: "C++ Variable Scope"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["local scope", "global scope", "shadowing", "C++ 변수 스코프"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "scope"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_scope.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Variable Scope]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter, and its exact example (a local `x=22` shadowing a global `x=5`), is IDENTICAL to C's Variable Scope chapter — confirming that C++'s scope rules, including the silent-shadowing behavior where same-named local and global variables coexist as two independent variables with no error, are inherited from C completely unmodified. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Scope** — the region where a variable is accessible; local (inside a function) or global (outside any function). [S1]
|
||||
- **Local scope** — a variable created inside a function only usable within it; error if accessed outside. [S1]
|
||||
- **Global scope** — accessible from ANY scope, both other functions and `main()`. [S1]
|
||||
- **Name collision = shadowing, not conflict** — a local variable with the SAME NAME as a global one creates two independent variables; the local one takes precedence inside its function. [S1]
|
||||
- **Global mutability risk** — any function can silently modify a global, making state harder to reason about. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Same-name shadowing — two independent variables coexist: `int x = 5; void myFunction() { int x = 22; cout << x; // 22, local } int main() { myFunction(); cout << x; // 5, global — untouched }`. [S1]
|
||||
- A function silently mutating a global: `int x = 5; void myFunction() { cout << ++x; } // x is now 6`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 스코프 규칙(섀도잉, 전역 변수 위험성)이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 기존 C++ 프로그램이나 협업 코드에서 전역 변수를 마주칠 가능성이 높으므로 스코프 동작 원리를 이해해두는 것이 실전에서 유용하다고 원문에 명시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A local variable shadowing a global variable of the same name (C++):
|
||||
```cpp
|
||||
int x = 5; // global
|
||||
void myFunction() {
|
||||
int x = 22; // local, shadows the global
|
||||
cout << x << "\n"; // 22 (local x)
|
||||
}
|
||||
int main() {
|
||||
myFunction();
|
||||
cout << x; // 5 (global x, untouched)
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Namespaces]], [[CPP User Input]], [[C Scope]]
|
||||
- **참조 맥락:** 변수 스코프 — 사용자 입력(User Input) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Variable Scope — https://www.w3schools.com/cpp/cpp_scope.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Variable Scope" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-sets
|
||||
title: "C++ Sets"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::set", "unique sorted elements C++", "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", "stl", "set"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_sets.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Sets]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`set` is the first STL container in this series where insertion ORDER is thrown away entirely — every container so far (vector/list/stack/queue/deque) preserved the order elements were added in, but a set auto-sorts on every insert AND silently drops duplicates, meaning `cars.insert("BMW")` twice is not an error, not a no-op that keeps the old value, but simply invisible — the second insert vanishes with no feedback, which is the opposite of the C mentality where writing the same array slot twice always visibly overwrites it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Automatic ascending sort** — elements are always kept in sorted order (alphabetical for strings, numeric for ints), regardless of insertion order. [S1]
|
||||
- **Uniqueness enforced silently** — inserting a duplicate value is simply ignored; no error, no exception, no indication. [S1]
|
||||
- **No index access, no in-place value change** — since order is determined by sorting rather than position, elements cannot be retrieved by `[i]`, and an existing element's VALUE cannot be modified (only added via `.insert()` or removed via `.erase()`). [S1]
|
||||
- **`greater<type>` functor** — passed as a second template parameter (`set<int, greater<int>> numbers`) to reverse the default ascending sort to descending. [S1]
|
||||
- **`.insert()` / `.erase()` / `.clear()`** — add one element / remove one specific element / remove everything. [S1]
|
||||
- **`.size()` / `.empty()`** — same semantics as other containers. [S1]
|
||||
- **Looping** — for-each only (like list); no indexed loop since there's no index. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration + auto-sort: `set<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};` prints in alphabetical order (BMW, Ford, Mazda, Volvo), NOT insertion order. [S1]
|
||||
- Numeric sets sort numerically: `set<int> numbers = {1, 7, 3, 2, 5, 9};` prints 1,2,3,5,7,9. [S1]
|
||||
- Descending order: `set<int, greater<int>> numbers = {1, 7, 3, 2, 5, 9};` prints 9,7,5,3,2,1. [S1]
|
||||
- Duplicate handling demonstrated directly: `set<string> cars = {"Volvo", "BMW", "Ford", "BMW", "Mazda"};` still prints only 4 unique elements. [S1]
|
||||
- Add/remove: `cars.insert("Tesla");` / `cars.erase("Volvo");` / `cars.clear();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **삽입 순서가 완전히 무시됨**: 지금까지의 모든 컨테이너(vector/list/stack/queue/deque)는 삽입 순서를 유지했지만, set은 매번 자동으로 정렬 순서를 재적용하여 삽입 순서 자체가 의미를 잃는다는 점이 이번 챕터에서 확인됨. [S1]
|
||||
- **중복 삽입이 조용히 무시됨**: C 배열에서 같은 인덱스에 값을 두 번 쓰면 항상 눈에 띄게 덮어써지지만, set에 같은 값을 두 번 insert()하면 아무 에러도 피드백도 없이 두 번째 삽입이 그냥 사라진다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 이름 set에 중복값을 넣어 자동으로 걸러지는 것을 보여주는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A set auto-sorts and silently drops duplicates on insert (C++):
|
||||
```cpp
|
||||
#include <set>
|
||||
set<string> cars = {"Volvo", "BMW", "Ford", "BMW", "Mazda"};
|
||||
// Output (sorted, deduplicated): BMW, Ford, Mazda, Volvo
|
||||
|
||||
set<int, greater<int>> numbers = {1, 7, 3, 2, 5, 9};
|
||||
// Descending via greater<type>: 9, 7, 5, 3, 2, 1
|
||||
|
||||
cars.insert("Tesla");
|
||||
cars.erase("Volvo");
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Deque]], [[CPP Maps]], [[CPP Iterators]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Maps 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Sets — https://www.w3schools.com/cpp/cpp_sets.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Sets" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: cpp-stacks
|
||||
title: "C++ Stacks"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["std::stack", "LIFO", "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", "stl", "stack", "lifo"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_stacks.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Stacks]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A `stack` is the STL's most restrictive container by design — it exposes ONLY `.top()`, deliberately hiding every other element, which is the opposite philosophy from vector's "give me any index" approach; this is a case where LESS access is the feature, because the LIFO guarantee (pancakes added/removed only from the top) is what makes stacks useful for problems like undo-history or call-stack simulation, and that guarantee would be broken if arbitrary access were allowed. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **LIFO (Last In, First Out)** — the defining order: the last element pushed is the first one that can be accessed or removed. [S1]
|
||||
- **`stack<type> name`** — requires `<stack>`; unlike vector/list, a stack CANNOT be initialized with a curly-brace list at declaration time — elements must be added via `.push()` after declaring. [S1]
|
||||
- **`.push()`** — adds an element to the top of the stack. [S1]
|
||||
- **`.top()`** — the ONLY way to read (or, via assignment, change) an element; always refers to the most recently pushed element. [S1]
|
||||
- **`.pop()`** — removes the top (most recently added) element; note this differs from vector's `.pop_back()` naming but same "remove from the active end" idea. [S1]
|
||||
- **`.size()` / `.empty()`** — same semantics as vector/list. [S1]
|
||||
- **Stacks and Queues are paired concepts** — the page explicitly notes queues (FIFO) are the mirror-image structure covered next. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration: `stack<string> cars;` then `cars.push("Volvo"); cars.push("BMW"); cars.push("Ford"); cars.push("Mazda");` — resulting order top-to-bottom: Mazda(top), Ford, BMW, Volvo. [S1]
|
||||
- Access/modify: `cars.top()` returns `"Mazda"`; `cars.top() = "Tesla";` changes only the top element. [S1]
|
||||
- Remove: `cars.pop();` removes Mazda, making Ford the new top. [S1]
|
||||
- Attempting `stack<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};` is explicitly called out as NOT allowed — a direct contrast to vector/list initialization syntax. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **선언 시 초기화가 불가능함**: vector와 list는 `= {...}` 중괄호 리스트로 선언과 동시에 초기화할 수 있었지만, stack은 선언 후 반드시 `.push()`로만 요소를 채울 수 있다는 제약이 이번 챕터에서 vector/list와의 차이로 명시됨. [S1]
|
||||
- **접근 가능한 요소가 단 하나(top)로 제한됨**: vector(인덱스 전체)·list(양 끝)에 비해 stack은 오직 top 요소 하나만 읽기/쓰기 가능하다는 점이 LIFO 보장을 위한 의도적 설계 제약으로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 이름을 push()로 쌓고 top()으로 확인하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Stack push/top/pop — only the top element is ever reachable (C++):
|
||||
```cpp
|
||||
#include <stack>
|
||||
stack<string> cars;
|
||||
cars.push("Volvo");
|
||||
cars.push("BMW");
|
||||
cars.push("Ford");
|
||||
cars.push("Mazda"); // top is now "Mazda"
|
||||
|
||||
cout << cars.top(); // "Mazda"
|
||||
cars.pop(); // removes "Mazda"
|
||||
cout << cars.top(); // now "Ford"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP List]], [[CPP Queues]], [[CPP Data Structures]]
|
||||
- **참조 맥락:** 데이터 구조(STL) 섹션 — Queues 챕터와 짝을 이루는 챕터, Queues로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Stacks — https://www.w3schools.com/cpp/cpp_stacks.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Stacks" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: cpp-statements
|
||||
title: "C++ Statements"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["semicolon", "C++ 명령문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "statements"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_statements.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Statements]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Just as in C, a missing semicolon produces an error message pointing to the NEXT statement rather than the actual offending line (`error: expected ';' before 'return'`) — the identical error-location quirk from the C tutorial carries over unchanged to C++, confirming both languages share the same underlying parser behavior for this specific mistake. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Statement** — one instruction executed by the compiler; the basic building block of a C++ program. [S1]
|
||||
- **Mandatory semicolon termination** — every statement must end with `;`; omitting it causes a compile error. [S1]
|
||||
- **Sequential execution** — multiple statements execute strictly top-to-bottom, in written order. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Missing-semicolon error: `cout << "Hello World!"` (no `;`) → `error: expected ';' before 'return'`. [S1]
|
||||
- Sequential multi-statement execution: `cout << "Hello World!"; cout << "Have a good day!"; return 0;` — runs top to bottom. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — C의 동일한 세미콜론 규칙과 에러 위치 특성이 그대로 이어진다는 점이 C 학습자가 C++로 전환할 때 유리한 지점이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Three statements executing sequentially in source order (C++):
|
||||
```cpp
|
||||
cout << "Hello World!";
|
||||
cout << "Have a good day!";
|
||||
return 0;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Syntax]], [[CPP Comments]]
|
||||
- **참조 맥락:** 명령문과 세미콜론 규칙 — 주석(Comments) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Statements — https://www.w3schools.com/cpp/cpp_statements.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-strings
|
||||
title: "C++ Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["string library include", "C++ 문자열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "strings"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike C, where storing multi-word text requires manually managing a `char` array and worrying about the null terminator, C++'s `string` type stores spaces and punctuation transparently ("Hello and welcome!" works with zero special handling) — proving that the earlier Data Types chapter's promise (string "behaves like" a built-in type) holds even for the exact scenario C explicitly warned about. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`string`** — stores a sequence of characters (text), double-quoted; requires `#include <string>`. [S1]
|
||||
- **Multi-word support with zero friction** — spaces and punctuation are stored and printed transparently, no escape handling or array sizing needed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic string with the required include: `#include <string> string greeting = "Hello"; cout << greeting;`. [S1]
|
||||
- Multi-word string with spaces and punctuation: `string greeting = "Hello and welcome!"; cout << greeting;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C의 다중 단어 문자열 문제가 C++에는 없음**: C에서는 char 배열의 크기와 널 종료 문자를 신경 써야 했지만, C++ string은 공백과 구두점을 포함한 여러 단어를 아무 특별 처리 없이 그대로 저장/출력한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — <string> 헤더 포함이 문자열을 다루는 모든 C++ 프로그램의 실전 필수 전제 조건이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A multi-word string with spaces and punctuation, stored and printed transparently (C++):
|
||||
```cpp
|
||||
#include <string>
|
||||
string greeting = "Hello and welcome!";
|
||||
cout << greeting;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Operators Precedence]], [[CPP Data Types String]], [[CPP Strings Access]]
|
||||
- **참조 맥락:** 문자열 섹션 첫 챕터 — 문자열 접근(Strings Access) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Strings — https://www.w3schools.com/cpp/cpp_strings.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-strings-access
|
||||
title: "C++ Access Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["string index", "at() function", "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", "strings", "indexing"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_access.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Access Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`myString.length() - 1` is the standard idiom for reaching the LAST character of a string of unknown length — since indexes are zero-based, the final valid index is always one less than the total length, and this exact formula reappears identically whether accessed via bracket indexing (`myString[myString.length() - 1]`) or the `.at()` function, showing the offset logic is independent of which access syntax is used. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Bracket indexing (`str[i]`)** — zero-based access to a string's characters, same convention as arrays. [S1]
|
||||
- **Last-character idiom** — `str[str.length() - 1]` reaches the final character regardless of the string's actual length. [S1]
|
||||
- **Mutable characters via index** — `myString[0] = 'J';` changes a specific character in place, using single quotes for the new value. [S1]
|
||||
- **`.at(index)` function** — an alternative to bracket indexing, from the `<string>` library, usable both for reading AND assigning (`myString.at(0) = 'J';`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- First and second character access: `string myString = "Hello"; cout << myString[0]; // H cout << myString[1]; // e`. [S1]
|
||||
- Last-character idiom: `cout << myString[myString.length() - 1]; // o`. [S1]
|
||||
- Mutating a character by index: `myString[0] = 'J'; cout << myString; // Jello`. [S1]
|
||||
- Using `.at()` for both reading and writing: `cout << myString.at(0); myString.at(0) = 'J'; cout << myString; // Jello`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — length()-1 공식으로 마지막 문자에 접근하는 패턴이 문자열 길이를 미리 알 수 없는 실전 상황에서 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reaching the last character of a string regardless of its length (C++):
|
||||
```cpp
|
||||
string myString = "Hello";
|
||||
cout << myString[myString.length() - 1]; // Outputs 'o'
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings]], [[CPP Strings Concat]], [[CPP Strings Length]]
|
||||
- **참조 맥락:** 문자열 접근 — 문자열 연결(Strings Concat) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Access Strings — https://www.w3schools.com/cpp/cpp_strings_access.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Access Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-strings-concat
|
||||
title: "C++ String Concatenation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["+ operator concatenation", "append() function", "C++ 문자열 연결"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "strings", "concatenation"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_concat.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C++ String Concatenation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source reveals that a C++ `string` is actually an OBJECT with member functions — not just a data container — proven by `append()` being callable ON the string itself (`firstName.append(lastName)`) as an alternative to the `+` operator, meaning string concatenation in C++ has TWO equally valid forms (operator-based and method-based) that reflect the object-oriented nature of the type, unlike C's char arrays which have no such method-call syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+` operator for concatenation** — joins two strings into a new one. [S1]
|
||||
- **Manual spacing** — a space must be explicitly included (either inside one of the strings or as a separate `" "` literal) since concatenation doesn't add spaces automatically. [S1]
|
||||
- **`.append()` method** — an alternative to `+` for concatenation, callable directly on a string object, reflecting that C++ strings are objects with member functions. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Concatenation with a space baked into one string: `string firstName = "John "; string lastName = "Doe"; string fullName = firstName + lastName; cout << fullName;`. [S1]
|
||||
- Concatenation with an explicit space literal: `string fullName = firstName + " " + lastName;`. [S1]
|
||||
- Concatenation via the `.append()` method: `string fullName = firstName.append(lastName); cout << fullName;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **문자열 연결에 자동 공백 삽입 없음**: firstName과 lastName을 그냥 더하면 공백 없이 붙기 때문에, 공백을 직접 문자열 안에 포함하거나 별도 " " 리터럴로 추가해야 한다는 점이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
이름(firstName)과 성(lastName)을 합쳐 전체 이름(fullName)을 만드는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Concatenating strings via the .append() method instead of the + operator (C++):
|
||||
```cpp
|
||||
string firstName = "John ";
|
||||
string lastName = "Doe";
|
||||
string fullName = firstName.append(lastName);
|
||||
cout << fullName;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Access]], [[CPP Strings Cstyle]], [[CPP Classes]]
|
||||
- **참조 맥락:** 문자열 연결 — C 스타일 문자열(Strings Cstyle) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ String Concatenation — https://www.w3schools.com/cpp/cpp_strings_concat.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ String Concatenation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-strings-cstyle
|
||||
title: "C++ C-Style Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["char array strings", "CString functions", "C++ C 스타일 문자열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "strings", "c-style"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_cstyle.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C++ C-Style Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C++ never removed C's original `char`-array string technique — it kept it fully supported alongside the modern `string` type specifically because it grants access to C standard library functions, meaning a C++ program can legally contain BOTH string styles simultaneously, and choosing C-style strings today is a deliberate interoperability decision, not a leftover habit from not knowing about `string`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **C-style string** — a `char` array (e.g. `char greeting2[] = "Hello";`), the original C technique, inherited and still supported in C++. [S1]
|
||||
- **Origin** — named after C, which lacks a native string type and represents text as character arrays. [S1]
|
||||
- **Why it persists in C++** — grants access to functions from the C standard library (CString functions). [S1]
|
||||
- **Modern recommendation** — the standard `string` type is more convenient for everyday use; C-style strings are a deliberate choice for specific interoperability needs. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Both string styles side by side: `string greeting1 = "Hello"; // Regular String char greeting2[] = "Hello"; // C-Style String (an array of characters)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — C 표준 라이브러리 함수에 접근해야 하는 상황이 C 스타일 문자열을 계속 사용하는 실전 이유로 원문에 직접 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The same text represented as a regular C++ string versus a C-style character array (C++):
|
||||
```cpp
|
||||
string greeting1 = "Hello"; // Regular String
|
||||
char greeting2[] = "Hello"; // C-Style String (an array of characters)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Concat]], [[CPP Strings Esc]], [[C Strings]]
|
||||
- **참조 맥락:** C 스타일 문자열 — 특수문자/이스케이프(Strings Esc) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ C-Style Strings — https://www.w3schools.com/cpp/cpp_strings_cstyle.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ C-Style Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: cpp-strings-esc
|
||||
title: "C++ Special Characters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["escape characters", "backslash escape", "C++ 이스케이프 문자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "strings", "escape-characters"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_esc.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Special Characters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The exact same double-quote-ambiguity problem and `\"` fix from C reappears unchanged in C++ — a literal `"` inside a double-quoted string is still fundamentally ambiguous to the compiler, requiring the identical `\"` escape to disambiguate where the string actually ends, confirming C++ inherited its escape-sequence grammar directly from C with no modification. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **The core problem** — double quotes delimit strings, so a literal `"` inside one prematurely ends the string. [S1]
|
||||
- **Core escape sequences** — `\'` (single quote), `\"` (double quote), `\\` (literal backslash). [S1]
|
||||
- **Other common escapes** — `\n` (newline), `\t` (tab). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Escaping double quotes inside a string: `string txt = "We are the so-called \"Vikings\" from the north.";`. [S1]
|
||||
- Escaping a single quote: `string txt = "It\'s alright.";`. [S1]
|
||||
- Escaping a literal backslash: `string txt = "The character \\ is called backslash.";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources). C 챕터와 완전히 동일한 이스케이프 규칙임이 확인됨.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 큰따옴표가 포함된 인용문을 문자열에 그대로 담아야 할 때 \" 이스케이프가 실전에서 바로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Escaping a literal double quote so it doesn't prematurely end the string (C++):
|
||||
```cpp
|
||||
string txt = "We are the so-called \"Vikings\" from the north.";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Cstyle]], [[CPP Strings Input]], [[C Strings Esc]]
|
||||
- **참조 맥락:** 이스케이프 문자 — 사용자 입력 문자열(Strings Input) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Special Characters — https://www.w3schools.com/cpp/cpp_strings_esc.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Special Characters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: cpp-strings-input
|
||||
title: "C++ User Input Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["cin extraction operator", "getline function", "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", "strings", "cin", "getline"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_input.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP User Input Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`cin >>` has the EXACT SAME whitespace-termination limitation as C's `scanf("%s", ...)` — typing "John Doe" only captures "John" — and C++'s fix (`getline(cin, fullName)`) mirrors C's `fgets()` fix conceptually, both existing specifically to read a full line including spaces, meaning this particular parsing limitation and its solution transferred from C to C++ despite the completely different I/O syntax (`>>`/`cin` versus `scanf`/format-strings). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`cin >> variable`** — the extraction operator, reads user input into a variable. [S1]
|
||||
- **`cin`'s whitespace-termination limitation** — treats spaces as a terminator, so it can only capture a SINGLE WORD even if the user types multiple words. [S1]
|
||||
- **`getline(cin, variable)`** — reads a FULL LINE of text including spaces; takes `cin` as the first parameter and the target string as the second. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic single-word input: `string firstName; cin >> firstName;`. [S1]
|
||||
- The space-termination trap demonstrated: `string fullName; cin >> fullName; // "John Doe" typed → only "John" stored`. [S1]
|
||||
- The `getline()` fix for multi-word input: `string fullName; getline (cin, fullName); // "John Doe" typed → "John Doe" stored in full`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **cin >>은 공백에서 끊김**: "John Doe"를 입력해도 공백을 종료 문자로 취급해 "John"만 저장된다는 점이 C의 scanf("%s") 문제와 동일하게 확인되며, getline()이 fgets()와 동일한 역할의 해결책으로 제시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
사용자의 전체 이름(공백 포함)을 정확히 입력받기 위해 cin >> 대신 getline()을 사용하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reading a full line of text (including spaces) with getline() instead of cin >> (C++):
|
||||
```cpp
|
||||
string fullName;
|
||||
cout << "Type your full name: ";
|
||||
getline(cin, fullName);
|
||||
cout << "Your name is: " << fullName; // "John Doe" prints in full
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Esc]], [[CPP Strings Length]], [[C User Input]]
|
||||
- **참조 맥락:** 사용자 입력 문자열 — 문자열 길이(Strings Length) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ User Input Strings — https://www.w3schools.com/cpp/cpp_strings_input.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ User Input Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user