← Back to archive

Stdle #54 · classes · 2026-07-30

What does this C++ snippet output?

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

#include <iostream>
struct Box { int v; };
void bump(Box& b) { b.v += 1; } // by ref
int main() {
Box a{41};
bump(a);
std::cout << a.v << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation