Team Ai
Apppublic

dwrswr/cpp-module-06-guide

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes
README.md88 linesDownload Raw Back to root
1---2title: "CPP Module 06 — Casts, Line by Line"3emoji: 🧭4colorFrom: purple5colorTo: green6sdk: static7app_file: index.html8pinned: false9license: mit10short_description: 42 C++ Module 06 walkthrough with a live converter11tags:12  - cpp13  - cpp9814  - 42school15  - "1337"16  - tutorial17  - static-cast18  - dynamic-cast19  - arabic20---21 22> **Read it live:** https://dwrswr-cpp-module-06-guide.static.hf.space  23> Everything below describes the files in this repository.24 25# CPP Module 06 — casts, explained line by line26 27A single-page guide to the 42 **C++ Module 06** project (`static_cast`,28`reinterpret_cast`, `dynamic_cast`), written against the code in `code/` rather than29against the subject in the abstract. Every file of `ex00`, `ex01` and `ex02` is shown in30full and annotated line by line; every terminal block is pasted from a real run.31 32Open `index.html`.33 34## What is inside35 36| section | what you get |37|---|---|38| 00 | what the module is really testing, and the file map of the project |39| 01 | the rules that decide the grade before the code is read, each with its cost |40| 02 | the four casts compared, plus a “which cast do I need?” picker |41| 03 | `ex00` — `ScalarConverter` line by line, 20 notes, a **live converter** and a table of the inputs worth knowing |42| 04 | `ex01` — `Serializer`, the `uintptr_t` round trip, and the `int` trap |43| 05 | `ex02` — `identify`, why `Base` needs `virtual`, and a pointer-vs-reference panel |44| 06 | the Makefile line by line and the commands to type |45| 07 | leaks and sanitizers, with what was actually verified |46| 08 | ten ways the module is normally lost |47| 09 | the correction sheet's own questions answered, plus five live-modification drills |48| 10 | a pre-defence checklist saved in the browser |49 50Three interactive panels, all hand-written with no dependencies: a **ScalarConverter51simulator**, a **`dynamic_cast` lab**, and the checklist. There is an **EN / العربية**52switch and a light/dark theme toggle in the top bar.53 54## Verified, not assumed55 56* All three exercises compile with `c++ -Wall -Wextra -Werror -std=c++98` (g++ 13.3.0)57  with zero warnings.58* Rebuilt with `-fsanitize=address,undefined` and run: no leaks, no undefined behaviour.59* The in-page converter was diffed against the compiled `./convert` on **46 literals**60  and agrees on all 46 — including `2147483647` → `float: 2147483648.0f`, the pseudo-literals,61  and every rejection.62* A grep across all fourteen source files for `printf`, `alloc`, `free`,63  `using namespace`, `friend`, `typeinfo` and `typeid` returns nothing.64 65## The page cannot drift from the code66 67`index.html` is generated. `tools/build.py` reads the real sources out of the project and68injects them into `tools/index.src.html`, so a code block on the page is the file on disk:69 70```bash71python tools/build.py     # rewrites index.html and refreshes code/72```73 74Translations are keyed by name in `assets/ar.js` (`data-i18n="s3.m14"`), not by position,75so adding or reordering a paragraph can never shift a translation onto the wrong element.76 77## Layout78 79```80index.html            the guide (generated)81assets/style.css      design system, dark + light82assets/app.js         theme, i18n, C++/Make tokeniser, the three widgets83assets/ar.js          Arabic dictionary, 319 keys84code/cpp06/           the project itself, ex00 / ex01 / ex0285tools/build.py        generator86tools/index.src.html  template87```88