← Back to archive

Stdle #103 · classes · 2026-09-17

What does this C++ snippet output?

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

#include <iostream>
int main() {
int x = 7;
const int& cr = x;
auto a = cr; // copy, drops const
const auto& b = cr; // alias, keeps const
x = 70;
std::cout << a << " " << b << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation