C++ Under the Hood: (Internal Class Mechanisms)
summary
Examines concrete C++ mechanics: object layout and why a vtable at offset zero makes base-to-derived casts work, how multiple inheritance produces adjusted this pointers and runtime offsets, and that compilers emit a thunk for pointer-to-member calls so virtual resolution still happens. Covers precise construction/destruction order (members forward, teardown reverse), static inline variables (C++17/20) and stack-frame calling convention details for walking and unwinding stacks. Notes an implementation quirk: a null member-pointer = -1 on some platforms.
AI-written summary · about
chapters (14)
- 0:00C++ class internals
- 1:26Object footprint and vtables
- 4:13Inheritance hierarchy
- 14:21Construction/destruction order
- 20:46Array construction rules
- 23:39Static members and globals
- 33:24Global object order
- 37:21Virtual functions inside constructors and destructors
- 44:28Raw vs member function pointers
- 52:15Member function pointers and virtual calls
- 1:00:42Pointer to member data
- 1:07:03Sorting with member pointers
- 1:10:59Stack frames in x86
- 1:19:09Summary
related talks
47m“Intro to the C++ Object Model"
58mClass Layout
51mC++ Features You Might Not Know
01h 22mThese 10 tricks that only library implementors know!
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
59mA Tour of C++ Recognised User Type Categories
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 02mOn the benefits of non-intrusiveness
