42·mindgap / CPP02 · map
📐 handbook ⏯ tracer 🧮 lab
cpp02 · flow boards

Seven boards / the shapes behind the module

Each board is one idea drawn once. They are the pictures the handbook explains at length and the tracer animates. Read them top to bottom the first time, then keep them as a reference.

board 1One class, four layers

One class, grown in place. A decision in the bottom layer is still alive at the top. That is why the copy constructor's delegation, chosen in ex00 to match a trace, still costs two lines per copy in ex03's 68 line bsp call.

handbook 00 · one class, four layers

board 2The build, or what the compiler sees

Two files include one contract. Both Fixed.cpp and main.cpp receive a textual copy of Fixed.hpp, which is why the include guard exists. Nothing in the header or the .cpp executes on its own; the program starts in main and calls into the catalogue.

handbook 01 · what the compiler sees

board 3Life of an object

Two rules, no exceptions in this module. A named object dies at its closing brace, and objects in one scope die in reverse order of birth. An unnamed temporary dies at the end of the full expression that made it, the semicolon. Every destructor line in every trace is one of these two events.

handbook Z5 · life of an object · tracer · watch the temporary

board 4Anatomy of one statement

Right side first, then assign, then clean up. The temporary is constructed, read by operator=, and destroyed, all before the next line of source runs. a is neither created nor destroyed here, only overwritten.

handbook Z5 · tracer · ex01 statement 5

board 5Who gets called · overload resolution

A short procedure, run at compile time. Collect the candidates, drop the ones that cannot take the arguments, rank how each remaining one converts, and either pick the unique best or refuse. The f suffix on 42.42f is the whole difference between a clean exact match and an ambiguity error.

handbook Z4 · who gets called · lab · try other literals

board 6Member versus free · what the syntax expands to

Operators are function calls with special spelling. Every member operator is a call on its left operand with this pointing at it. operator<< is the exception because the left operand is a stream you do not own, so it lives outside the class, and min / max are static because comparing two objects is nobody's method.

handbook Z6 · handbook Z7 · the mechanical map

board 7The bsp sign test

Three edges, three signs, one question: do they agree? Inside means the point is on the same side of every edge. A zero means it sits exactly on an edge's line, which the subject counts as outside. Accepting both all positive and all negative makes the answer independent of the order the vertices were listed in.

handbook E3 · Point and bsp · lab · drag the point · tracer · the 68 lines of one call