1.

Virtual function is ______ class function which expected to be redefined in ______ class, so that when reference is made to derived class object using pointer then we can call virtual function to execute ________ class definition version.(a) Base, derived, derived(b) Derived, Derived, Derived(c) Base, derived, base(d) Base, base, derivedThis question was addressed to me in unit test.I need to ask this question from Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (a) Base, derived, derived

Easy explanation - The functions which MAY give rise to ambiguity due to INHERITANCE, can be declared virtual. So that whenever derived class object is referred using pointer or REFERENCE to the base class methods, we can still call the derived class methods using virtual FUNCTION. Hence this differentiates those methods from each other.



Discussion

No Comment Found

Related InterviewSolutions