1.

Which among the following best describes member function overriding?(a) Member functions having same name in base and derived classes(b) Member functions having same name in base class only(c) Member functions having same name in derived class only(d) Member functions having same name and different signature inside main functionI have been asked this question in semester exam.My question comes from Overriding Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer» CORRECT choice is (a) Member functions having same name in base and derived classes

The best I can explain: The member function which is defined in base class and again in the derived class, is overridden by the definition GIVEN in the derived class. This is because the preference is given more to the local members. When derived class OBJECT calls that function, definition from the derived class is used.


Discussion

No Comment Found

Related InterviewSolutions