All challenges
Code AnalysisBeginner 60s

Slicing when passing derived by value

What is the output and why?
Starter code
#include <iostream>
struct Base { virtual void who() const { std::cout << "base\n"; } };
struct Derived : Base { void who() const override { std::cout << "derived\n"; } };

void call(Base b) { b.who(); }

int main() { Derived d; call(d); }

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle