← Back to archive

Stdle #38 · modern · 2026-07-14

What does this C++ snippet output?

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

#include <iostream>
int main() {
int x = 10;
auto f = [&]() { return [=]() { return x; }; };
auto g = f();
x = 20;
std::cout << g() << "\n";
}
Modern
4 attempts left

Answer & explanation