Medium
A virtual call on a local object
Compiled with -O2, does the call obj.speak() go through the vtable at runtime?
main.cpp
struct Animal {
virtual void speak() const { }
};
struct Dog : Animal {
void speak() const override { /* barks */ }
};
void run() {
Dog obj; // concrete local object, not a pointer or reference
obj.speak(); // (1)
}22 of 44 in Compilers