fbpx

C++ Interview Question 7 Answer

Bjarne-stroustrup
 

Answer

This question is compilable and deterministic.

Its output is “A”.

Explanation

As long as A::f() is not virtual, A::f() will always be called, even if the reference or pointer is actually referring to an object of type B.

SOURCE