← Back to archive

Stdle #176 · overload · 2026-11-29

What does this C++ snippet output?

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

#include <iostream>
struct V {
int x;
friend std::ostream& operator<<(std::ostream& os, const V& v) {
return os << "V(" << v.x << ")";
}
};
int main() {
V v{42};
std::cout << v << "\n";
}
Overload
4 attempts left

Answer & explanation