📖 Book · cpp core · high
🪤 C++ Gotchas & Trick Questions
Guess-the-output traps, and the rule behind each one
The growing collection of C++ trap questions interviewers use to tell memorisation from understanding: new int vs new int() vs new int(5), () vs {} and the most vexing parse, signed/unsigned and overflow, dangling references and iterator invalidation, virtual-call-in-constructor, slicing, name hiding, and 0/NULL/nullptr. Well-defined examples run live; the undefined ones are flagged as UB instead of pretending an output is canonical. Each trap ends in the one rule that explains it.
7 chapters▶ runnable code✦ in-depth animation
What this book covers
- 01How to survive a trap question
- 02Initialization traps
- 03Integers & undefined behaviour
- 04Lifetime & dangling traps
- 05Polymorphism traps
- 06Overloads & conversions
- 07The rules behind every trap
Read it in full — runnable C++ + step-through animations
Every chapter of C++ Gotchas & Trick Questions ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.