← Back to archive

Stdle #4 · 2026-06-10

What does this log?

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

#include <iostream>
struct Handler {
virtual int handle(int x) { return x; }
};
struct Doubler : Handler {
int handle(int x) override { return x * 2; }
};
int main() {
Handler* h = new Doubler();
std::cout << h->handle(21) << "\n";
delete h;
}
Virtual
4 attempts left

Answer & explanation