Stdle #77 · virtual · 2026-08-22
What does this C++ snippet output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
#include <iostream> struct A { virtual int who() { return 1; } };struct B : A { int who() override { return 2; } };struct C : B { int who() override { return 3; } };int main() { A* arr[3] = { new A(), new B(), new C() }; for (auto p : arr) std::cout << p->who() << " "; std::cout << "\n";}Virtual