Multiple ChoiceBeginner 45s
Default argument vs virtual dispatch
A base and derived both define `f(int x = 1)` and `f(int x = 2)` as virtual. Calling via `Base* b = new Derived; b->f();` uses:
Options
- 1Both the default argument and the function body are taken from Derived, since it is the dynamic type.
- 2The default argument from the static type (Base, so 1) but the function body from the dynamic type (Derived).
- 3Both the default argument and the function body are taken from Base, since it is the static type.
- 4A compile error, because default arguments are not permitted to appear on a virtual function declaration.
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.