What this C++ polymorphism question tests
This is a medium-difficulty C++ language-knowledge question that probes your understanding of how polymorphism, virtual functions, and object slicing behave in practice. It rewards careful reading of code semantics over memorization of syntax rules.
To answer correctly, you need to trace through the code mentally and predict the runtime behaviour, paying close attention to how virtual function calls are resolved, whether base and derived class methods interact as expected, and whether any implicit type conversions or object copies occur. The question may involve subtle interactions between inheritance, method binding, and memory layout that are easy to overlook.
- Virtual function dispatch and method resolution order
- Object slicing and pointer/reference semantics
- Implicit conversions and copy semantics in inheritance hierarchies
- The difference between compile-time and runtime behaviour