← Back to archive

Stdle #152 · raii · 2026-11-05

What does this C++ snippet output?

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

#include <iostream>
struct Tracked {
Tracked() { std::cout << "C\n"; }
Tracked(const Tracked&) { std::cout << "Cp\n"; }
~Tracked() { std::cout << "D\n"; }
};
void byValue(Tracked t) { std::cout << "in\n"; }
int main() {
Tracked t;
byValue(t);
std::cout << "back\n";
}
RAII
6 lines
4 attempts left

Answer & explanation