1.

In which access specifier should a virtual function be defined?(a) Private(b) Public(c) Protected(d) DefaultThis question was addressed to me by my school principal while I was bunking the class.The question is from Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right CHOICE is (b) Public

For explanation: The VIRTUAL functions must be defined in public section of a class. This is to ensure that the virtual function is available EVERYWHERE in the program. ALSO to avoid any error while RESOLVING the method.



Discussion

No Comment Found

Related InterviewSolutions