docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: cpp-strings-numbers
|
||||
title: "C++ Numbers and Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["+ operator overload", "string vs number addition", "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", "operator-overloading"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_strings_numbers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Numbers and Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`+` isn't ONE operator with one behavior — it's overloaded to mean completely different things depending on operand type: numeric `+` performs arithmetic addition (`"10" + "20"` as ints = `30`), while string `+` performs concatenation (`"10" + "20"` as strings = `"1020"`), and mixing the two (a string plus a number) is explicitly flagged as an ERROR — meaning `+`'s meaning is entirely determined by the DECLARED TYPES of its operands, with no automatic conversion bridging string and number. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+` on numbers** — performs arithmetic addition: `int x = 10; int y = 20; int z = x + y; // 30`. [S1]
|
||||
- **`+` on strings** — performs concatenation, NOT addition: `string x = "10"; string y = "20"; string z = x + y; // "1020"`. [S1]
|
||||
- **Mixing string and number with `+` fails** — `string x = "10"; int y = 20; string z = x + y;` produces an error; there's no automatic string-to-number or number-to-string coercion for `+`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Numeric addition: `int x = 10; int y = 20; int z = x + y; // z will be 30 (an integer)`. [S1]
|
||||
- String concatenation with the SAME `+` symbol producing a totally different result: `string x = "10"; string y = "20"; string z = x + y; // z will be 1020 (a string)`. [S1]
|
||||
- The explicit error case: `string x = "10"; int y = 20; string z = x + y; // error`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **+ 연산자는 피연산자 타입에 따라 완전히 다른 동작**: 숫자끼리는 산술 덧셈, 문자열끼리는 연결(concatenation)을 수행하며, 문자열과 숫자를 섞어서 더하면 에러가 발생한다는 점이 "WARNING!"으로 강조되어 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 사용자 입력이 숫자처럼 보여도 실제로는 문자열(string) 타입일 수 있어, + 연산 시 의도치 않게 덧셈 대신 연결이 일어날 수 있다는 점을 실전에서 주의해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The + operator meaning completely different things for numbers vs. strings (C++):
|
||||
```cpp
|
||||
int x = 10;
|
||||
int y = 20;
|
||||
int z = x + y; // z will be 30 (an integer)
|
||||
|
||||
string a = "10";
|
||||
string b = "20";
|
||||
string z2 = a + b; // z2 will be "1020" (a string)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Strings Namespace]], [[CPP Math]], [[CPP Operators Arithmetic]]
|
||||
- **참조 맥락:** 문자열 섹션 마지막 — 수학 함수(Math) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Numbers and Strings — https://www.w3schools.com/cpp/cpp_strings_numbers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Numbers and Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user