Caffeinated Coder
Book an appointment
Lesson 13 · Classes

Constructors and destructors

Every C++ object has a lifetime with a fixed start and a fixed end. The constructor runs when an object is created and sets it up; the destructor runs, automatically, when its lifetime ends. Follow three Cup objects through one small program, see a closing brace destroy them in the reverse order they were made, and meet RAII, the idea that makes C++ clean up after itself.

11 min9 steps5 questionsIntermediate
Fig 13 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.