← Back to archive

Stdle #23 · classes · 2026-06-29

What does this C++ snippet output?

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

#include <iostream>
int main() {
int a = 2, b = 5;
int& ra = a;
int& rb = b;
int t = ra; ra = rb; rb = t; // swaps a and b
std::cout << a << " " << b << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation