--- id: cpp-syntax title: "C++ Syntax" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["using namespace std", "cout", "std::", "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", "syntax", "namespace"] raw_sources: ["https://www.w3schools.com/cpp/cpp_syntax.asp"] applied_in: [] github_commit: "" --- # [[CPP Syntax]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `using namespace std;` is entirely OPTIONAL and can be replaced everywhere by prefixing each standard-library name with `std::` (`std::cout` instead of `cout`) β€” both forms are equally valid, but the tutorial deliberately chooses the shorter `using namespace std;` form for teaching purposes, explicitly flagging that real-world/larger C++ programs often prefer the more explicit `std::` form to avoid naming conflicts β€” meaning the "beginner-friendly" style and the "production" style are known to diverge from the very first syntax lesson. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`#include `** β€” header enabling input/output objects like `cout`. [S1] - **`using namespace std;`** β€” allows using standard-library names (like `cout`) without the `std::` prefix. [S1] - **`cout` + `<<`** β€” the object and insertion operator used to print text/output. [S1] - **Case sensitivity** β€” `cout` and `Cout` are different identifiers. [S1] - **`std::` alternative** β€” omitting `using namespace std;` and prefixing each name with `std::` instead (e.g. `std::cout`) is equally valid, avoids naming conflicts, and is more common in larger/advanced programs. [S1] - **Whitespace insignificance** β€” same as C: blank lines/extra spaces are ignored by the compiler, used only for readability. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Standard tutorial style: `#include using namespace std; int main() { cout << "Hello World!"; return 0; }`. [S1] - Equivalent `std::`-prefixed style without the namespace declaration: `#include int main() { std::cout << "Hello World!"; return 0; }`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **using namespace std;λŠ” 선택 사항**: std:: 접두사λ₯Ό 맀번 λΆ™μ΄λŠ” 방식과 μ™„μ „νžˆ λ™λ“±ν•˜λ©°, 이름 μΆ©λŒμ„ ν”Όν•˜κΈ° μœ„ν•΄ 싀무/λŒ€κ·œλͺ¨ ν”„λ‘œκ·Έλž¨μ—μ„œλŠ” std::λ₯Ό λͺ…μ‹œμ μœΌλ‘œ μ“°λŠ” κ²½μš°κ°€ λ§Žλ‹€λŠ” 점이 확인됨 β€” νŠœν† λ¦¬μ–Όμ€ ν•™μŠ΅ 편의λ₯Ό μœ„ν•΄ using namespace std;λ₯Ό 주둜 μ‚¬μš©. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 이름 좩돌 λ°©μ§€λ₯Ό μœ„ν•œ std:: λͺ…μ‹œμ  μ‚¬μš©μ΄ λŒ€κ·œλͺ¨ ν”„λ‘œκ·Έλž¨μ—μ„œμ˜ μ‹€μ „ κ΄€ν–‰μœΌλ‘œ 언급됨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) The equivalent std:: prefix form without using namespace std (C++): ```cpp #include int main() { std::cout << "Hello World!"; return 0; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.87 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C++ Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CPP Get Started]], [[CPP Statements]], [[CPP Namespaces]] - **μ°Έμ‘° λ§₯락:** C++ ν”„λ‘œκ·Έλž¨ ꡬ쑰 β€” λͺ…λ Ήλ¬Έ(Statements) μ±•ν„°λ‘œ 이어짐, λ„€μž„μŠ€νŽ˜μ΄μŠ€(Namespaces) 챕터와 직접 μ—°κ²°. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C++ Syntax β€” https://www.w3schools.com/cpp/cpp_syntax.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C++ Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).