← Back to archive

Stdle #79 · raii · 2026-08-24

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
struct Noisy {
int id;
Noisy(int i) : id(i) { std::cout << "ctor " << id << "\n"; }
~Noisy() { std::cout << "dtor " << id << "\n"; }
};
int main() {
Noisy a(1), b(2), c(3);
std::cout << "made\n";
}
RAII
7 lines
4 attempts left

Answer & explanation