#1770mediumC++ & Systems
Virtual Dispatch During Construction
Consider the following C++ program:
#include <iostream>
struct Base {
Base() { whoami(); }
virtual void whoami() { std::cout << "Base\n"; }
virtual ~Base() = default;
};
struct Derived : Base {
void whoami() override { std::cout << "Derived\n"; }
};
int main() {
Derived d;
}
What happens when this program runs?
Loading interactive editor…