“Intro to the C++ Object Model"
summary
Shows how objects map to memory: member functions become a hidden this parameter and are name‑mangled, and virtuals compile to a vtable pointer inserted as first member with a separate table of function pointers placed in read‑only text. Constructors initialize that pointer — constructor sets vptr — so virtual calls in constructors dispatch to the base type. Uses make, GCC/Clang and c++filt for examples; adding virtuals moves a 2‑float struct from 8 bytes to 16 and a million objects can cost ~8 MB.
AI-written summary · about
chapters (13)
- 0:00Introduction to C++ object model
- 2:52Object-oriented programming basics
- 5:48C vs C++ struct memory layout
- 7:34Classes vs structs in C++
- 10:44Inheritance in C++ objects
- 12:28Member functions and this pointer
- 15:45Polymorphism with virtual functions
- 22:11Adding virtual functions to classes
- 24:03How vtables work in C++
- 28:01Constructors and vtable pointers
- 30:30Virtual functions in constructors
- 33:01Summary of C++ object model
- 33:24Q&A on virtual functions and vtables
related talks
01h 26mC++ Under the Hood: (Internal Class Mechanisms)
49mC++: Objects, their lifetime and pointers
01h 36mObject-Oriented Program: Best Practices
55mHow to "OO" in C++
01h 31mThe C++ Vector Challenge
01h 21mAn (In-)Complete Guide to C++ Object Lifetimes
01h 23mElsewhere Memory (C++20 Abstract Machine) + Virtual Memory
55mBreaking Dependencies: Type Erasure - The Implementation Details
