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