← Back to archive

Stdle #147 · classes · 2026-10-31

What does this C++ snippet output?

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

#include <iostream>
int main() {
int x = 6;
const int& r = x; // auto& would keep const
auto v = r; // auto drops const+ref: copy
v = 100;
std::cout << r << " " << v << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation