1.

Which among the following is true for virtual functions?(a) Prototype must be different in base and derived class(b) Prototype must be same in base class and derived class(c) Prototype must be given only in base class(d) Prototype must have different signature in base and derived classI had been asked this question by my college professor while I was bunking the class.I need to ask this question from Virtual Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (B) Prototype must be same in BASE class and derived class

The EXPLANATION is: The prototype must be the same. Because the function is to be OVERRIDDEN in the derived class. If the function prototype is different in derived class then it will not override the base class function and hence virtual function concept won’t work here.



Discussion

No Comment Found

Related InterviewSolutions