Stdle #180 · overload · 2026-12-03
What does this C++ snippet output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
#include <iostream> struct Counter { int n = 0; Counter& operator++() { ++n; return *this; } Counter operator++(int) { Counter t = *this; ++n; return t; }};int main() { Counter c; int a = (++c).n; int b = (c++).n; std::cout << a << " " << b << " " << c.n << "\n";}Overload