--- id: cpp-debugging title: "C++ Debugging" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["print debugging", "breakpoints", "debugging vs exception handling", "C++ 디버깅"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.84 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["cpp", "programming-language", "w3schools", "debugging"] raw_sources: ["https://www.w3schools.com/cpp/cpp_debugging.asp"] applied_in: [] github_commit: "" --- # [[CPP Debugging]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The closing distinction ("debugging is about finding/fixing errors DURING DEVELOPMENT; exception handling is dealing with errors WHILE THE PROGRAM RUNS") is IDENTICAL to C's Debugging chapter's conclusion β€” except in C++, "exception handling" now refers to a REAL language feature (`try`/`catch`) rather than C's manual NULL-checking workarounds, meaning the conceptual division between the two development-vs-runtime phases stays the same across languages, but the runtime-side tool it points to is genuinely more powerful in C++. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Print debugging** β€” using `cout` to trace how far execution gets before something goes wrong. [S1] - **Checking variable values** β€” printing intermediate results to catch LOGIC errors, not just crashes. [S1] - **IDE debuggers** β€” breakpoints, line-by-line stepping, variable-watching; recommended as a step up once comfortable with print debugging. [S1] - **Reading error messages literally** β€” the compiler states exactly what's wrong and where. [S1] - **Debugging vs. exception handling** β€” debugging finds/fixes mistakes DURING DEVELOPMENT; exception handling responds to problems WHILE THE PROGRAM RUNS β€” the same C-established distinction, but now backed by C++'s real try/catch mechanism instead of C's manual workarounds. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Print debugging locating a crash point: `cout << "Before division\n"; int z = x / y; // crashes cout << "After division\n"; // never runs`. [S1] - Logic-error detection via variable printing: `int result = x - y; cout << "Result: " << result << "\n"; // expected 15, got 5 β€” wrong operator used`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **디버깅과 μ˜ˆμ™Έ 처리의 ꡬ뢄은 C와 λ™μΌν•˜μ§€λ§Œ μ˜ˆμ™Έ 처리 μžμ²΄λŠ” 더 κ°•λ ₯함**: 개발 쀑 디버깅 vs μ‹€ν–‰ 쀑 μ—λŸ¬ λŒ€μ‘μ΄λΌλŠ” ꡬ뢄은 C와 κ°™μ§€λ§Œ, C++μ—μ„œλŠ” κ·Έ "μ‹€ν–‰ 쀑 λŒ€μ‘" μˆ˜λ‹¨μ΄ μ§„μ§œ μ–Έμ–΄ μ°¨μ›μ˜ try/catchλΌλŠ” 점이 C의 μˆ˜λ™μ  μš°νšŒμ±…κ³Ό λŒ€λΉ„λ¨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” cout으둜 μ½”λ“œ μ‹€ν–‰ 지점을 좔적해 ν¬λž˜μ‹œ μœ„μΉ˜λ₯Ό μ°ΎλŠ” print debugging이 μ‹€μ „μ—μ„œ κ°€μž₯ λ¨Όμ € μ‹œλ„ν•˜λŠ” 디버깅 κΈ°λ²•μœΌλ‘œ ꢌμž₯됨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Print debugging to locate exactly where a program crashes (C++): ```cpp int x = 10; int y = 0; cout << "Before division\n"; // Debug output int z = x / y; // Crashes! cout << "After division\n"; // Never runs β€” crash located ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.84 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C++ Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CPP Input Validation]], [[CPP Exceptions]], [[CPP Files]] - **μ°Έμ‘° λ§₯락:** μ—λŸ¬ 및 디버깅 μ„Ήμ…˜ λ§ˆμ§€λ§‰ β€” 파일 μž…μΆœλ ₯(Files) μ„Ήμ…˜μœΌλ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C++ Debugging β€” https://www.w3schools.com/cpp/cpp_debugging.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C++ Debugging" page (Astra wiki-curation, P-Reinforce v3.1 format).