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