← Back to archive

Stdle #94 · raii · 2026-09-08

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);
std::cout << "body\n";
}
RAII
3 lines
4 attempts left

Answer & explanation