C++17/20 · 15 QUESTIONS · ABOUT 12 MINUTES

Every object is born, and every one dies.

C++ gives you control over exactly when things happen, and expects you to know. Fifteen snippets on references, lifetimes, virtual calls, moves and templates, each explained. No sign-up, nothing saved.

Start the C++ test
struct T {  T() { cout << "+"; }  ~T() { cout << "-"; }};{ T a; T b; }
output++--
QUESTION 1 / 15 · BASICS & REFERENCESEasy

What does this print?

int a = 1;int& r = a;r = 5;cout << a;

What this C++ test measures, in short

This test checks whether you can predict what real C++ does: when constructors and destructors run, how references and pointers alias, which function a virtual call reaches, what a move leaves behind, and how templates and the STL behave.

Snippets assume C++17 or later with <iostream> and using namespace std. Questions avoid undefined behaviour so each has one correct answer. They're our own and not standardised, so treat the result as a knowledge check, not a certification.

By What's Your IQ · Reviewed 4 Oct 2026
Format
15 predict-the-output questions, 4 options each
Topics
Basics and references, object lifetime, classes and virtual, move semantics, templates and STL
Standard
C++17, with a few C++20 notes
Language
Created by Bjarne Stroustrup at Bell Labs, from 1979
RAII, LINE BY LINE

The stack cleans up after you

Objects on the stack are destroyed in reverse order when their scope ends, even if an exception is thrown. Tie a resource to an object and it can't leak. That idea is RAII.

STACK (TOP FIRST)
(empty)
OUTPUT
Entering run(). The stack frame is empty.
C WITH CLASSES → MODERN C++

Same job, fewer ways to get it wrong

OLD STYLE
Widget* w = new Widget();if (!w->init()) { return false; // leak!}use(w);delete w;
MODERN
auto w = make_unique<Widget>();if (!w->init()) { return false; // freed}use(*w);

Every early return or exception between new and delete is a leak. unique_ptr deletes automatically when it goes out of scope.

Every 3 yearsa new ISO standard shipsSince C++11, the committee has released on a fixed train: 14, 17, 20, 23, with C++26 next. Features that miss the train wait for the next one.2
1979 → 1985C with Classes. Bjarne Stroustrup added classes to C at Bell Labs; renamed C++ in 1983, it was released commercially in 1985.1
1998First ISO standard. C++98 included the Standard Template Library, built on Alexander Stepanov's generic programming work.1
2011Modern C++. C++11 brought move semantics, auto, lambdas and smart pointers. Stroustrup said it felt like a new language.3
2020Concepts, ranges, modules. C++20 was the biggest update since 11, letting templates state their requirements directly.2
  1. Stroustrup, B. (1994). The design and evolution of C++. Addison-Wesley.
  2. ISO/IEC JTC1/SC22/WG21. Standard C++ status and schedule. isocpp.org.
  3. Stroustrup, B. (2013). The C++ programming language (4th ed.). Addison-Wesley.

Where to go next

You can track every object. How's your working memory?

Our full IQ test measures the reasoning and working memory that C++ leans on: 60 questions across four domains, about 30 minutes.

Take the full IQ test