← Back to archive

Stdle #33 · classes · 2026-07-09

What does this C++ snippet output?

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

#include <iostream>
int main() {
int x = 3;
const int& a = x; // a binds to x
const int& b = 10; // b binds to a temporary
x = 50;
std::cout << a << " " << b << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation