--- 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).